[trivial-shell-devel] Request to Add Following : setenv and getenv
Gary King
gwking at metabang.com
Tue Aug 18 21:24:45 UTC 2009
Hi Seth,
FWIW, trivial-shell already has `get-env-var`. It doesn't have set-env-
var though so I'll add that. (or, probably, (setf get-env-var). Maybe
I'll even rename things to lose the abbreviations: get-environment-
variable!
thanks,
On Aug 14, 2009, at 2:11 PM, Seth wrote:
> 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
>
> _______________________________________________
> trivial-shell-devel mailing list
> trivial-shell-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/trivial-shell-devel
--
Gary Warren King, metabang.com
Cell: (413) 559 8738
Fax: (206) 338-4052
gwkkwg on Skype * garethsan on AIM * gwking on twitter
More information about the Trivial-shell-devel
mailing list