From dc7e8fae48f65da7aea86043a25a9381b678ebe6 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 18 Feb 2015 15:55:18 +0100 Subject: [PATCH] Support passing command line arguments to nix-shell #! scripts --- scripts/nix-build.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/nix-build.in b/scripts/nix-build.in index b497d8f5a..c7c516212 100755 --- a/scripts/nix-build.in +++ b/scripts/nix-build.in @@ -30,6 +30,7 @@ my $myName = $runEnv ? "nix-shell" : "nix-build"; my $inShebang = 0; my $script; +my @savedArgs; my $tmpDir = mkTempDir($myName); @@ -43,13 +44,14 @@ $SIG{'INT'} = sub { exit 1 }; # Heuristic to see if we're invoked as a shebang script, namely, if we # have a single argument, it's the name of an executable file, and it # starts with "#!". -if ($runEnv && scalar @ARGV == 1) { +if ($runEnv && $ARGV[0] !~ /nix-shell/) { $script = $ARGV[0]; if (-f $script && -x $script) { open SCRIPT, "<$script" or die "$0: cannot open ‘$script’: $!\n"; my $first =