summaryrefslogtreecommitdiffstats
path: root/lib/shell.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-09-19 20:42:27 +0200
committertv <tv@krebsco.de>2017-09-19 20:42:27 +0200
commit8179f87e5a434ebb21219b657c05a11e6811525f (patch)
tree39c98530747b8a4b37ee65c8ed83164349a7d982 /lib/shell.nix
parent3416a45b54e092c6b9b24738aa44d3c217982c26 (diff)
lib shell.escape: escape the empty string as ''
Diffstat (limited to 'lib/shell.nix')
-rw-r--r--lib/shell.nix11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/shell.nix b/lib/shell.nix
index f9779028e..5be8d6759 100644
--- a/lib/shell.nix
+++ b/lib/shell.nix
@@ -7,10 +7,13 @@ rec {
let
isSafeChar = testString "[-+./0-9:=A-Z_a-z]";
in
- stringAsChars (c:
- if isSafeChar c then c
- else if c == "\n" then "'\n'"
- else "\\${c}");
+ x:
+ if x == "" then "''"
+ else stringAsChars (c:
+ if isSafeChar c then c
+ else if c == "\n" then "'\n'"
+ else "\\${c}"
+ ) x;
#
# shell script generators