summaryrefslogtreecommitdiffstats
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
commita68f3df85a6e2e2776562c75226a7ef403262c50 (patch)
tree942514d2737e2b7a2516fec26fe14e2acc84a18a
parentcabe8d5394ec864d739832c8079625b9987c9bf8 (diff)
lib shell.escape: escape the empty string as ''
-rw-r--r--lib/shell.nix11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/shell.nix b/lib/shell.nix
index f977902..5be8d67 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