enhance escapeShellArg funtion. It should be pretty correct now
svn path=/nixpkgs/trunk/; revision=15475
This commit is contained in:
parent
16ca65b0c2
commit
8cc8965379
|
@ -66,11 +66,14 @@ rec {
|
||||||
else [(substring 0 1 s)] ++ stringToCharacters (substring 1 (builtins.sub l 1) s);
|
else [(substring 0 1 s)] ++ stringToCharacters (substring 1 (builtins.sub l 1) s);
|
||||||
|
|
||||||
|
|
||||||
# !!! this function seems broken - it doesn't escape all special
|
# same as vim escape function.
|
||||||
# characters, and in any case this should be done in a builder.
|
# Each character contained in list is prefixed by "\"
|
||||||
escapeShellArg = s:
|
escape = list : string :
|
||||||
let escapeChar = x: if x == "'" then "'\"'\"'" else x;
|
lib.concatStrings (map (c: if lib.elem c list then "\\${c}" else c) (stringToCharacters string));
|
||||||
in "'" + concatStrings (map escapeChar (stringToCharacters s)) + "'";
|
|
||||||
|
# still ugly slow. But more correct now
|
||||||
|
# [] for zsh
|
||||||
|
escapeShellArg = lib.escape (stringToCharacters "\\ ';$`()|<>\t*[]");
|
||||||
|
|
||||||
|
|
||||||
# !!! what is this for?
|
# !!! what is this for?
|
||||||
|
|
Loading…
Reference in New Issue