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: Fixes use with ruby shebangs. #2056
Conversation
The ported code in 80ebc55 was incorrectly ported. ``` - $envCommand = "exec $execArgs $interpreter -e 'load(\"$script\")' -- ${\(join ' ', (map shellEscape, @savedArgs))}"; ... + envCommand = (format("exec %1% %2% -e 'load(\"%3%\") -- %4%") % execArgs % interpreter % script % joined.str()).str(); ``` The single-quote finishing the small ruby snippet was lost in translation.
The test fakes the interpreter only to verify the arguments it would be given.
I have added a The test only verifies the command line that would be passed to the ruby interpreter and does not actually test with a ruby interpreter. For the purpose of this PR, the test is sufficient. Executing the test after reverting the fix commit gives me these errors:
This matches with what was observable without tests. A similar test could be added for the perl shebang handling if pertinent. I would like feedback about what I did wrong with the test :). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one small nit. Good catch!
tests/nix-shell.sh
Outdated
# Test nix-shell shebang mode for ruby | ||
# This uses a fake interpreter that returns the arguments passed | ||
# This, in turn, verifies the `rc` script is valid and the `load()` script (given using `-e`) is as expected. | ||
sed -e "s|@ENV_PROG@|$(type -p env)|" shell.shebang.rb > $TEST_ROOT/shell.shebang.rb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just hard-code the path to nix-shell instead?
... in the ruby shebang test.
It has been amended so it uses the path to While I did make the change, I would like to know why shoult it use the path to |
Mostly just to remove the unnecessary indirection and need to resolve |
No problem! Thanks! |
The ported code in 80ebc55 was incorrectly ported.
The single-quote finishing the small ruby snippet was lost in
translation.
Symptoms:
In addition, I will be looking at how tests work, but I would really like to add a test for this regression. Any help is welcome.