mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
feat: break out of shebang processing for non-comments
This commit is contained in:
parent
01f61cefcb
commit
06f3583b1c
2 changed files with 12 additions and 11 deletions
|
@ -121,7 +121,8 @@ void Args::parseCmdline(const std::string & programName, const Strings & _cmdlin
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
std::getline(stream,line);
|
std::getline(stream,line);
|
||||||
while (std::getline(stream,line) && !line.empty()){
|
std::string commentChars("#/\\%@*-");
|
||||||
|
while (std::getline(stream,line) && !line.empty() && commentChars.find(line[0]) != std::string::npos){
|
||||||
line = chomp(line);
|
line = chomp(line);
|
||||||
|
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
|
|
|
@ -80,17 +80,17 @@ chmod +x "$nonFlakeDir/shebang.sh"
|
||||||
git -C "$nonFlakeDir" add README.md shebang.sh
|
git -C "$nonFlakeDir" add README.md shebang.sh
|
||||||
git -C "$nonFlakeDir" commit -m 'Initial'
|
git -C "$nonFlakeDir" commit -m 'Initial'
|
||||||
|
|
||||||
cat > $nonFlakeDir/shebang-perl.sh <<EOF
|
cat > $nonFlakeDir/shebang-comments.sh <<EOF
|
||||||
#! $(type -P env) nix
|
#! $(type -P env) nix
|
||||||
#! nix run nixpkgs#perl
|
# some comments
|
||||||
## Modules used
|
# some comments
|
||||||
use strict;
|
# some comments
|
||||||
use warnings;
|
#! nix --offline shell
|
||||||
|
#! nix flake1#fooScript
|
||||||
# Print function
|
#! nix --no-write-lock-file --command bash
|
||||||
print("Hello World\n");
|
foo
|
||||||
EOF
|
EOF
|
||||||
chmod +x $nonFlakeDir/shebang-perl.sh
|
chmod +x $nonFlakeDir/shebang-comments.sh
|
||||||
|
|
||||||
# Construct a custom registry, additionally test the --registry flag
|
# Construct a custom registry, additionally test the --registry flag
|
||||||
nix registry add --registry "$registry" flake1 "git+file://$flake1Dir"
|
nix registry add --registry "$registry" flake1 "git+file://$flake1Dir"
|
||||||
|
@ -538,4 +538,4 @@ expectStderr 1 nix flake metadata "$flake2Dir" --no-allow-dirty --reference-lock
|
||||||
# Test shebang
|
# Test shebang
|
||||||
[[ $($nonFlakeDir/shebang.sh) = "foo" ]]
|
[[ $($nonFlakeDir/shebang.sh) = "foo" ]]
|
||||||
[[ $($nonFlakeDir/shebang.sh "bar") = "foo"$'\n'"bar" ]]
|
[[ $($nonFlakeDir/shebang.sh "bar") = "foo"$'\n'"bar" ]]
|
||||||
[[ $($nonFlakeDir/shebang-perl.sh ) = "Hello World!" ]]
|
[[ $($nonFlakeDir/shebang-comments.sh ) = "foo" ]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue