1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-03 06:11:46 +02:00

Refactor: rename left -> remainingArgs

This commit is contained in:
Robert Hensing 2024-07-06 20:03:30 +02:00
parent 13181356fc
commit 5c367ece89

View file

@ -100,7 +100,7 @@ static void main_nix_build(int argc, char * * argv)
// Same condition as bash uses for interactive shells // Same condition as bash uses for interactive shells
auto interactive = isatty(STDIN_FILENO) && isatty(STDERR_FILENO); auto interactive = isatty(STDIN_FILENO) && isatty(STDERR_FILENO);
Strings attrPaths; Strings attrPaths;
Strings left; Strings remainingArgs;
BuildMode buildMode = bmNormal; BuildMode buildMode = bmNormal;
bool readStdin = false; bool readStdin = false;
@ -246,7 +246,7 @@ static void main_nix_build(int argc, char * * argv)
return false; return false;
else else
left.push_back(*arg); remainingArgs.push_back(*arg);
return true; return true;
}); });
@ -276,16 +276,16 @@ static void main_nix_build(int argc, char * * argv)
if (packages) { if (packages) {
std::ostringstream joined; std::ostringstream joined;
joined << "{...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) \"shell\" { buildInputs = [ "; joined << "{...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) \"shell\" { buildInputs = [ ";
for (const auto & i : left) for (const auto & i : remainingArgs)
joined << '(' << i << ") "; joined << '(' << i << ") ";
joined << "]; } \"\""; joined << "]; } \"\"";
fromArgs = true; fromArgs = true;
left = {joined.str()}; remainingArgs = {joined.str()};
} else if (!fromArgs) { } else if (!fromArgs) {
if (left.empty() && isNixShell && pathExists("shell.nix")) if (remainingArgs.empty() && isNixShell && pathExists("shell.nix"))
left = {"shell.nix"}; remainingArgs = {"shell.nix"};
if (left.empty()) if (remainingArgs.empty())
left = {"default.nix"}; remainingArgs = {"default.nix"};
} }
if (isNixShell) if (isNixShell)
@ -299,7 +299,7 @@ static void main_nix_build(int argc, char * * argv)
if (readStdin) if (readStdin)
exprs = {state->parseStdin()}; exprs = {state->parseStdin()};
else else
for (auto i : left) { for (auto i : remainingArgs) {
if (fromArgs) if (fromArgs)
exprs.push_back(state->parseExprFromString(std::move(i), state->rootPath("."))); exprs.push_back(state->parseExprFromString(std::move(i), state->rootPath(".")));
else { else {