mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-01-23 11:36:47 +02: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
1 changed files with 4 additions and 2 deletions
|
@ -298,7 +298,9 @@ static void main_nix_build(int argc, char * * argv)
|
||||||
else
|
else
|
||||||
for (auto i : left) {
|
for (auto i : left) {
|
||||||
if (fromArgs)
|
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 {
|
else {
|
||||||
auto absolute = i;
|
auto absolute = i;
|
||||||
try {
|
try {
|
||||||
|
@ -311,7 +313,7 @@ static void main_nix_build(int argc, char * * argv)
|
||||||
/* If we're in a #! script, interpret filenames
|
/* If we're in a #! script, interpret filenames
|
||||||
relative to the script. */
|
relative to the script. */
|
||||||
exprs.push_back(state->parseExprFromFile(resolveExprPath(state->checkSourcePath(lookupFileArg(*state,
|
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 a new issue