100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
(uname #f))
(if (null? (car uname-res))
"unknown"
(caar uname-res))))
(define (save-environment-as-files fname)
(let ((envvars (get-environment-variables))
(whitesp (regexp "[^a-zA-Z0-9_\\-:;,.\\/%]")))
(with-output-to-file (conc fname ".csh")
(lambda ()
(for-each (lambda (key)
(let* ((val (cdr key))
(sval (if (string-search whitesp val)(conc "'" val "'") val)))
(print "setenv " (car key) " " sval)))
envvars)))
(with-output-to-file (conc fname ".sh")
(lambda ()
(for-each (lambda (key)
(let* ((val (cdr key))
(sval (if (string-search whitesp val)(conc "'" val "'") val)))
(print "export " (car key) "=" sval)))
envvars)))))
;; set some env vars from an alist, return an alist with original values
;; (("VAR" "value") ...)
(define (alist->env-vars lst)
(if (list? lst)
|
|
|
|
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
(uname #f))
(if (null? (car uname-res))
"unknown"
(caar uname-res))))
(define (save-environment-as-files fname)
(let ((envvars (get-environment-variables))
(whitesp (regexp "[^a-zA-Z0-9_\\-:;,.\\/%$]")))
(with-output-to-file (conc fname ".csh")
(lambda ()
(for-each (lambda (key)
(let* ((val (cdr key))
(sval (if (string-search whitesp val)(conc "\"" val "\"") val)))
(print "setenv " (car key) " " sval)))
envvars)))
(with-output-to-file (conc fname ".sh")
(lambda ()
(for-each (lambda (key)
(let* ((val (cdr key))
(sval (if (string-search whitesp val)(conc "\"" val "\"") val)))
(print "export " (car key) "=" sval)))
envvars)))))
;; set some env vars from an alist, return an alist with original values
;; (("VAR" "value") ...)
(define (alist->env-vars lst)
(if (list? lst)
|