aboutsummaryrefslogtreecommitdiff
path: root/gnu/home/services
diff options
context:
space:
mode:
authorLudovic Courtès <ludovic.courtes@inria.fr>2023-07-06 16:53:21 +0200
committerLudovic Courtès <ludo@gnu.org>2023-07-11 15:47:56 +0200
commit7d9fdfb19d17dc99a4cf2548942c4f8ae7433572 (patch)
treef305e9345d55cf2e60fe76f34c8ffe3f2d687e9f /gnu/home/services
parentfe3321f91ae331d3f1d4a389f28fdf02f74da7e8 (diff)
downloadguix-7d9fdfb19d17dc99a4cf2548942c4f8ae7433572.tar
guix-7d9fdfb19d17dc99a4cf2548942c4f8ae7433572.tar.gz
home: services: bash: Properly quote shell aliases.
Fixes <https://issues.guix.gnu.org/63048>. Reported by Ekaitz Zarraga <ekaitz@elenq.tech>. * gnu/home/services.scm (with-shell-quotation-bindings): New procedure. (environment-variable-shell-definitions): Use it instead of inline copy. * gnu/home/services/shells.scm (bash-serialize-aliases): Use it. Add clause for 'literal-string?'. * tests/guix-home.sh: Add 'aliases' to 'home-bash-extension' and test it.
Diffstat (limited to 'gnu/home/services')
-rw-r--r--gnu/home/services/shells.scm28
1 files changed, 18 insertions, 10 deletions
diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm
index 415b5470c5..7960590e7c 100644
--- a/gnu/home/services/shells.scm
+++ b/gnu/home/services/shells.scm
@@ -313,16 +313,24 @@ source ~/.profile
;;;
(define (bash-serialize-aliases field-name val)
- #~(string-append
- #$@(map
- (match-lambda
- ((key . #f)
- "")
- ((key . #t)
- #~(string-append "alias " #$key "\n"))
- ((key . value)
- #~(string-append "alias " #$key "=\"" #$value "\"\n")))
- val)))
+ (with-shell-quotation-bindings
+ #~(string-append
+ #$@(map
+ (match-lambda
+ ((key . #f)
+ "")
+ ((key . #t)
+ #~(string-append "alias " #$key "\n"))
+ ((key . (? literal-string? value))
+ #~(string-append "alias " #$key "="
+ (shell-single-quote
+ #$(literal-string-value value))
+ "\n"))
+ ((key . value)
+ #~(string-append "alias " #$key "="
+ (shell-double-quote #$value)
+ "\n")))
+ val))))
(define-configuration home-bash-configuration
(package