diff options
author | tv <tv@krebsco.de> | 2017-09-19 20:42:27 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2017-09-19 20:42:27 +0200 |
commit | 8179f87e5a434ebb21219b657c05a11e6811525f (patch) | |
tree | 39c98530747b8a4b37ee65c8ed83164349a7d982 | |
parent | 3416a45b54e092c6b9b24738aa44d3c217982c26 (diff) |
lib shell.escape: escape the empty string as ''
-rw-r--r-- | lib/shell.nix | 11 |
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 |