source: trunk/abcl/contrib/posix-syscalls/system.lisp

Last change on this file was 15700, checked in by Mark Evenson, 12 months ago

Create POSIX-SYSCALLS contrib to set environment variables

Based on code provided by Alan Ruttenberg in
<https://github.com/alanruttenberg/lsw2/blob/owlapiv4/util/setenv.lisp>.

See
<https://mailman.common-lisp.net/pipermail/armedbear-devel/2023-April/004308.html>
ff.

See <file:contrib/posix-syscalls/posix-syscalls.org>.

File size: 743 bytes
Line 
1(in-package :system/posix-syscalls)
2
3;;; Currently unused, but save original symbol functions
4(defvar *ext--getenv*
5  #'ext:getenv)
6(defvar *uiop/os--getenv*
7  #'uiop/os:getenv)
8
9(eval-when (:load-toplevel)
10  (when
11      (c-library-reference)
12    (defun ext:getenv (variable)
13      (getenv variable))
14    (defsetf ext:getenv (variable) (value)
15      `(progn
16         (when (= (putenv ,variable ,value)
17                0)
18           ,value)))
19    (setf (symbol-function 'uiop/os:getenv)
20          'getenv)
21    ;;; XXX figure out how to reuse the ext:getenv expander?
22    (defsetf uiop/os:getenv (variable) (value)
23      `(progn
24         (when (= (putenv ,variable ,value)
25                  0)
26           ,value)))))
27
28         
29
30
31
32
33     
34
35   
Note: See TracBrowser for help on using the repository browser.