-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nix-shell in second #! line only accepts double quotes for package expressions #2356
Comments
This actually just bit me a few days ago while trying to use a |
This is a regression. I got the exact same error on a haskell script I've used succesfully before. |
Needs single quote handling in nix/src/nix-build/nix-build.cc Line 53 in a0ef212
|
Not only package expression is affected, but any expression in single quotes. The problem is that inner double quotes need to be escaped: #! /usr/bin/env nix-shell
#! nix-shell -E "with import <nixpkgs> {}; runCommand \"dummy\" {} \"\"" |
I marked this as stale due to inactivity. → More info |
For those, who needs long/complex nix expression in shebang in a single file, I've found a semi-solution with the help of |
I marked this as stale due to inactivity. → More info |
This works:
This does not:
Running a script with the above lines produces:
error: syntax error, unexpected $undefined, at (string):1:94
The syntax of the extra
#! nix-shell
lines looks like we're writing shell command syntax, so people think that bash-like (or at least sh-like) quoting rules would apply.Ideally single quotes would work as well as double quotes, but either way the manual (https://nixos.org/nix/manual/#ssec-nix-shell-shebang) should at talk about how to properly quote complex arguments; currently none of the examples need quoting, and there is no mention of whether any kind of quoting is supported or not (which leads to the guess that bash-like quotes would be supported from the similar syntax).
The text was updated successfully, but these errors were encountered: