diff options
| author | Andrew Tropin <andrew@trop.in> | 2023-01-09 12:22:56 +0400 |
|---|---|---|
| committer | Andrew Tropin <andrew@trop.in> | 2023-01-09 12:22:56 +0400 |
| commit | 35ecbb418c03e3957ebab87af921742466fe2de9 (patch) | |
| tree | a8e524be0b4167b67ab539285476edbd6fd00cb1 | |
| parent | 2acce55a00df9344d73101bb57a3961ba86105b0 (diff) | |
home: environment-variables: Fix escaping.
* gnu/home/services.scm (environment-variable-shell-definitions): Fix
escaping.
* tests/guix-home.sh: Add STRING_WITH_ESCAPES environment variable and test
its value.
Reported-by: elevnkb
| -rw-r--r-- | gnu/home/services.scm | 2 | ||||
| -rw-r--r-- | tests/guix-home.sh | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/gnu/home/services.scm b/gnu/home/services.scm index c442da374c7..b17a34d19da 100644 --- a/gnu/home/services.scm +++ b/gnu/home/services.scm | |||
| @@ -192,7 +192,7 @@ ensures variable values are properly quoted." | |||
| 192 | (list->string (string-fold-right | 192 | (list->string (string-fold-right |
| 193 | (lambda (chr lst) | 193 | (lambda (chr lst) |
| 194 | (if (memq chr quoted-chars) | 194 | (if (memq chr quoted-chars) |
| 195 | (append (list chr #\\) lst) | 195 | (append (list #\\ chr) lst) |
| 196 | (cons chr lst))) | 196 | (cons chr lst))) |
| 197 | '() | 197 | '() |
| 198 | value)))) | 198 | value)))) |
diff --git a/tests/guix-home.sh b/tests/guix-home.sh index 83ca6e72c87..3151f666834 100644 --- a/tests/guix-home.sh +++ b/tests/guix-home.sh | |||
| @@ -84,8 +84,9 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT | |||
| 84 | home-environment-variables-service-type | 84 | home-environment-variables-service-type |
| 85 | `(("TODAY" . "26 messidor") | 85 | `(("TODAY" . "26 messidor") |
| 86 | ("SHELL" . ,(file-append bash "/bin/bash")) | 86 | ("SHELL" . ,(file-append bash "/bin/bash")) |
| 87 | ("BUILDHOSTTIME" . ,#~(strftime "%c" | 87 | ("BUILDHOST_TIME" . ,#~(strftime "%c" |
| 88 | (localtime (current-time)))) | 88 | (localtime (current-time)))) |
| 89 | ("STRING_WITH_ESCAPES" . "chars: \" /\\") | ||
| 89 | ("LITERAL" . ,(literal-string "${abc}")))) | 90 | ("LITERAL" . ,(literal-string "${abc}")))) |
| 90 | 91 | ||
| 91 | (simple-service 'home-bash-service-extension-test | 92 | (simple-service 'home-bash-service-extension-test |
| @@ -157,6 +158,8 @@ EOF | |||
| 157 | ( . "${HOME}/.guix-home/setup-environment"; test "$TODAY" = "26 messidor" ) | 158 | ( . "${HOME}/.guix-home/setup-environment"; test "$TODAY" = "26 messidor" ) |
| 158 | ( . "${HOME}/.guix-home/setup-environment"; test "$LITERAL" = '${abc}' ) | 159 | ( . "${HOME}/.guix-home/setup-environment"; test "$LITERAL" = '${abc}' ) |
| 159 | ( . "${HOME}/.guix-home/setup-environment"; | 160 | ( . "${HOME}/.guix-home/setup-environment"; |
| 161 | test "$STRING_WITH_ESCAPES" = "chars: \" /\\") | ||
| 162 | ( . "${HOME}/.guix-home/setup-environment"; | ||
| 160 | echo "$SHELL" | grep "/gnu/store/.*/bin/bash" ) | 163 | echo "$SHELL" | grep "/gnu/store/.*/bin/bash" ) |
| 161 | 164 | ||
| 162 | # This one should still be here. | 165 | # This one should still be here. |
