From 8179f87e5a434ebb21219b657c05a11e6811525f Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 19 Sep 2017 20:42:27 +0200 Subject: lib shell.escape: escape the empty string as '' --- lib/shell.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/shell.nix b/lib/shell.nix index f9779028..5be8d675 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 -- cgit v1.2.3