[Nix-dev] builtins.toString and escapeShellArg ?
Marc Weber
marco-oweber at gmx.de
Fri Jul 10 21:53:30 CEST 2009
let pkgs = (import /etc/nixos/nixpkgs/pkgs/top-level/all-packages.nix) {};
a = pkgs.lib.escapeShellArg ";${pkgs.perl}";
b = pkgs.lib.escapeShellArg ";/nix/store/foo";
in "${a} ${b}"
Str(";/nix/store/75aca8292zhnxsbm7whfcpgys1fbww3g-perl-5.10.0 \\;/nix/store/foo",["/nix/store/sgf6q7g20rh35cqbp5n31pz0s058dla3-perl-5.10.0.drv"])
^^^^ ^^^^
I'd expect that both ; get escaped. However only the second one which is not
near by the real store path get's escaped?
implementation of escape and escapeShellArg can be found in lib/strings.nix:
# same as vim escape function.
# Each character contained in list is prefixed by "\"
escape = list : string :
lib.concatStrings (map (c: if lib.elem c list then "\\${c}" else c) (stringToCharacters string));
# still ugly slow. But more correct now
# [] for zsh
escapeShellArg = lib.escape (stringToCharacters "\\ ';$`()|<>\t*[]");
Marc Weber
More information about the nix-dev
mailing list