Skip to content

Commit

Permalink
nix develop: Preserve stdin with -c
Browse files Browse the repository at this point in the history
  • Loading branch information
Kha committed Nov 7, 2020
1 parent 387f824 commit 4f14917
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/nix/develop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ struct CmdDevelop : Common, MixEnvironment
std::vector<std::string> args;
for (auto s : command)
args.push_back(shellEscape(s));
script += fmt("exec %s\n", concatStringsSep(" ", args));
script += concatStringsSep(" ", args);
}

else {
Expand Down Expand Up @@ -474,9 +474,9 @@ struct CmdDevelop : Common, MixEnvironment
ignoreException();
}

// If running a phase, don't want an interactive shell running after
// If running a phase or single command, don't want an interactive shell running after
// Ctrl-C, so don't pass --rcfile
auto args = phase ? Strings{std::string(baseNameOf(shell)), rcFilePath}
auto args = phase || !command.empty() ? Strings{std::string(baseNameOf(shell)), rcFilePath}
: Strings{std::string(baseNameOf(shell)), "--rcfile", rcFilePath};

restoreAffinity();
Expand Down
1 change: 1 addition & 0 deletions tests/nix-shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ output=$($TEST_ROOT/shell.shebang.rb abc ruby)

# Test 'nix develop'.
nix develop -f shell.nix shellDrv -c bash -c '[[ -n $stdenv ]]'
echo foo | nix develop -f shell.nix shellDrv -c cat # preserve stdin with `-c`

# Test 'nix print-dev-env'.
source <(nix print-dev-env -f shell.nix shellDrv)
Expand Down

0 comments on commit 4f14917

Please sign in to comment.