summary refs log tree commit diff
path: root/gnu/home
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/home')
-rw-r--r--gnu/home/services/shells.scm34
1 files changed, 24 insertions, 10 deletions
diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm
index 27190934f0..28d717f03d 100644
--- a/gnu/home/services/shells.scm
+++ b/gnu/home/services/shells.scm
@@ -111,16 +111,30 @@ service type can be extended with a list of file-like objects.")))
 
 (define (serialize-boolean field-name val) "")
 (define (serialize-posix-env-vars field-name val)
-  #~(string-append
-     #$@(map
-         (match-lambda
-           ((key . #f)
-            "")
-           ((key . #t)
-            #~(string-append "export " #$key "\n"))
-           ((key . value)
-            #~(string-append "export " #$key "=" #$value "\n")))
-         val)))
+  #~(let ((shell-quote
+           (lambda (value)
+             ;; Double-quote VALUE, leaving dollar sign as is.
+             (let ((quoted (list->string
+                            (string-fold-right
+                             (lambda (chr lst)
+                               (case chr
+                                 ((#\" #\\)
+                                  (append (list chr #\\) lst))
+                                 (else (cons chr lst))))
+                             '()
+                             value))))
+               (string-append "\"" quoted "\"")))))
+      (string-append
+       #$@(map
+           (match-lambda
+             ((key . #f)
+              "")
+             ((key . #t)
+              #~(string-append "export " #$key "\n"))
+             ((key . value)
+              #~(string-append "export " #$key "="
+                               (shell-quote #$value) "\n")))
+           val))))
 
 
 ;;;