From 1595b6fde693d80a8864ffa9bb36676e85142d2a Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" <rpgoldman@gmail.com> Date: Sun, 30 Nov 2014 12:15:53 -0600 Subject: [PATCH] DEFSETF GETENV added. Needed for some testing. --- uiop/os.lisp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/uiop/os.lisp b/uiop/os.lisp index 3306ced5..98462e39 100644 --- a/uiop/os.lisp +++ b/uiop/os.lisp @@ -76,7 +76,6 @@ that is neither Unix, nor Windows, nor Genera, nor even old MacOS.~%Now you port (detect-os)) ;;;; Environment variables: getting them, and parsing them. - (with-upgradability () (defun getenv (x) "Query the environment, as in C getenv. @@ -109,6 +108,21 @@ use getenvp to return NIL in such a case." #-(or abcl allegro clisp clozure cmu cormanlisp ecl gcl genera lispworks mcl mkcl sbcl scl xcl) (error "~S is not supported on your implementation" 'getenv)) + + (defsetf getenv (x) (val) + "Set an environment variable." + (declare (ignorable x val)) + #+clisp `(system::setenv ,x ,val) + #+ecl `(ext:setenv ,x ,val) + #+allegro `(setf (sys:getenv ,x) ,val) + #+clozure `(ccl:setenv ,x ,val) + #+cmu `(unix:unix-setenv ,x ,val 1) + #+lispworks `(hcl:setenv ,x ,val) + #+mkcl `(mkcl:setenv ,x ,val) + #+sbcl `(progn (require :sb-posix) (symbol-call :sb-posix :setenv ,x ,val 1)) + #-(or allegro clisp clozure ecl lispworks mkcl sbcl cmu) + '(error "SETF ~S is not supported on your implementation" 'getenv)) + (defun getenvp (x) "Predicate that is true if the named variable is present in the libc environment, then returning the non-empty string value of the variable" -- GitLab