[trivial-shell-devel] Request to Add Following : setenv and getenv

Seth seth at tewebs.com
Fri Aug 14 18:11:37 UTC 2009


Setting Environment Variables. Notice that its envget instead of getenv because
lispworks already has 
such a exported symbol

(defun envget (var &optional (nullret ""))
  (let ((env #+clisp (ext:getenv (if (equalp var "") " " var))
             #+sbcl (sb-posix:getenv var)
             #+ecl (si:getenv var)
             #+allegro (sys:getenv var)
             #+lispworks (lw:environment-variable var)
             #-(or clisp sbcl ecl allegro lispworks) (error "GETENV is not
supported for your implementation")))
    #+clisp (if (equalp env "") nullret env)
    #+(or sbcl allegro lispworks ecl) (if (null env) nullret env)))

(defun envset (var content)
  (let 
    ((it #+clisp (setf (ext:getenv var) content)
         #+sbcl (sb-posix:putenv (concatenate 'string var "=" content))
         #+ecl (si:setenv var content)
         #+allegro (setf (sys:getenv var) content)
         #+lispworks (setf (lw:environment-variable var) content) 
         #-(or clisp sbcl ecl allegro lispworks) 
         (error "SETENV is not supported for your implementation")))
    #+sbcl (if (= it 0) content nil)
    #+(or lispworks clisp allegro ecl) (if it content)))

(defun (setf envget) (var content)
  (setenv var content))


---- Msg sent via WebMail




More information about the Trivial-shell-devel mailing list