about summary refs log tree commit diff
path: root/scripts/nix-build.in
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-02-18T19·13+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-02-18T19·13+0100
commit1816ac0db1817642e27ef1544c7d9b904dbb670a (patch)
tree9b032b23384079fa9f1a200a68d3dfe63c7b44f7 /scripts/nix-build.in
parentdc7e8fae48f65da7aea86043a25a9381b678ebe6 (diff)
Escape arguments to nix-shell #! scripts
Diffstat (limited to 'scripts/nix-build.in')
-rwxr-xr-xscripts/nix-build.in8
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/nix-build.in b/scripts/nix-build.in
index c7c516212801..19de6feb6080 100755
--- a/scripts/nix-build.in
+++ b/scripts/nix-build.in
@@ -195,8 +195,12 @@ for (my $n = 0; $n < scalar @ARGV; $n++) {
         # or (undocumented) argv[0] does not contain "perl". Exploit
         # the latter by doing "exec -a".
         my $execArgs = $interpreter =~ /perl/ ? "-a PERL" : "";
-        # FIXME: escape arguments.
-        $envCommand = "exec $execArgs $interpreter $script @savedArgs";
+        sub shellEscape {
+            my $s = $_;
+            $s =~ s/'/'\\''/g;
+            return "'" . $s . "'";
+        }
+        $envCommand = "exec $execArgs $interpreter $script ${\(join ' ', (map shellEscape, @savedArgs))}";
     }
 
     elsif (substr($arg, 0, 1) eq "-") {