Escape arguments to nix-shell #! scripts
This commit is contained in:
parent
dc7e8fae48
commit
1816ac0db1
1 changed files with 6 additions and 2 deletions
|
@ -195,8 +195,12 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
|
||||||
# or (undocumented) argv[0] does not contain "perl". Exploit
|
# or (undocumented) argv[0] does not contain "perl". Exploit
|
||||||
# the latter by doing "exec -a".
|
# the latter by doing "exec -a".
|
||||||
my $execArgs = $interpreter =~ /perl/ ? "-a PERL" : "";
|
my $execArgs = $interpreter =~ /perl/ ? "-a PERL" : "";
|
||||||
# FIXME: escape arguments.
|
sub shellEscape {
|
||||||
$envCommand = "exec $execArgs $interpreter $script @savedArgs";
|
my $s = $_;
|
||||||
|
$s =~ s/'/'\\''/g;
|
||||||
|
return "'" . $s . "'";
|
||||||
|
}
|
||||||
|
$envCommand = "exec $execArgs $interpreter $script ${\(join ' ', (map shellEscape, @savedArgs))}";
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif (substr($arg, 0, 1) eq "-") {
|
elsif (substr($arg, 0, 1) eq "-") {
|
||||||
|
|
Loading…
Reference in a new issue