mirror of
https://github.com/NixOS/nix.git
synced 2024-11-25 00:02:25 +00:00
Evaluate nix-shell -i args relative to script
When writing a shebang script, you expect your path to be relative to the script, not the cwd. We previously handled this correctly for relative file paths, but not for expressions. This handles both -p & -E args. My understanding is this should be what we want in any cases I can think of - people run scripts from many different working directories. @edolstra is there any reason to handle -p args differently in this case? Fixes #4232
This commit is contained in:
parent
f0180487a0
commit
04023360ed
@ -298,7 +298,9 @@ static void main_nix_build(int argc, char * * argv)
|
||||
else
|
||||
for (auto i : left) {
|
||||
if (fromArgs)
|
||||
exprs.push_back(state->parseExprFromString(std::move(i), state->rootPath(CanonPath::fromCwd())));
|
||||
exprs.push_back(state->parseExprFromString(
|
||||
std::move(i),
|
||||
state->rootPath(CanonPath::fromCwd(inShebang ? dirOf(script) : "."))));
|
||||
else {
|
||||
auto absolute = i;
|
||||
try {
|
||||
@ -311,7 +313,7 @@ static void main_nix_build(int argc, char * * argv)
|
||||
/* If we're in a #! script, interpret filenames
|
||||
relative to the script. */
|
||||
exprs.push_back(state->parseExprFromFile(resolveExprPath(state->checkSourcePath(lookupFileArg(*state,
|
||||
inShebang && !packages ? absPath(i, absPath(dirOf(script))) : i)))));
|
||||
inShebang ? absPath(i, absPath(dirOf(script))) : i)))));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user