@@ -38,18 +38,19 @@ (append newalist (list (list key val))))) (define (config:eval-string-in-environment str) (let ((cmdres (cmd-run->list (conc "echo " str)))) (if (null? cmdres) "" - (car cmdres)))) + (caar cmdres)))) ;; read a config file, returns hash table of alists ;; adds to ht if given (must be #f otherwise) ;; envion-patt is a regex spec that identifies sections that will be eval'd ;; in the environment on the fly (define (read-config path ht allow-system #!key (environ-patt #f)) + (debug:print 4 "INFO: read-config " path " allow-system " allow-system " environ-patt " environ-patt) (if (not (file-exists? path)) (if (not ht)(make-hash-table) ht) (let ((inp (open-input-file path)) (res (if (not ht)(make-hash-table) ht)) (include-rx (regexp "^\\[include\\s+(.*)\\]\\s*$")) @@ -89,14 +90,19 @@ (string-intersperse res " "))))) (hash-table-set! res curr-section-name (config:assoc-safe-add alist key val)) (loop (read-line inp) curr-section-name #f #f)) (loop (read-line inp) curr-section-name #f #f))) - (key-val-pr ( x key val ) (let ((alist (hash-table-ref/default res curr-section-name '())) - (realval (if (and environ-patt (string-match (regexp environ-patt) curr-section-name)) + (key-val-pr ( x key val ) (let* ((alist (hash-table-ref/default res curr-section-name '())) + (envar (and environ-patt (string-match (regexp environ-patt) curr-section-name))) + (realval (if envar (config:eval-string-in-environment val) val))) + (if envar + (begin + (debug:print 4 "INFO: read-config key=" key ", val=" val ", realval=" realval) + (setenv key realval))) (hash-table-set! res curr-section-name (config:assoc-safe-add alist key realval)) (loop (read-line inp) curr-section-name key #f))) ;; if a continued line (cont-ln-rx ( x whsp val ) (let ((alist (hash-table-ref/default res curr-section-name '())))