lib shell.escape: escape the empty string as ''

This commit is contained in:
tv 2017-09-19 20:42:27 +02:00
parent 3416a45b54
commit 8179f87e5a

View File

@ -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