nix: develop: always force SHELL to chosen shell

SHELL was inherited from the system environment. This resulted in a new
shell being started, but with SHELL still referring to the system shell
and not the one used by nix-develop.

Applications like make, use SHELL to run commands, which meant that
top-level commands are run inside the nix-develop-shell, but
sub-commands are ran inside the system shell.

This setenv forces SHELL to always be set to the shell used by
nix-develop.
This commit is contained in:
Bob van der Linden 2023-03-13 21:14:19 +01:00
parent e34c424279
commit 8c54a01df5
No known key found for this signature in database
GPG key ID: EEBE8E3EC4A31364

View file

@ -293,7 +293,6 @@ struct Common : InstallableCommand, MixProfile
"NIX_LOG_FD",
"NIX_REMOTE",
"PPID",
"SHELL",
"SHELLOPTS",
"SSL_CERT_FILE", // FIXME: only want to ignore /no-cert-file.crt
"TEMP",
@ -643,6 +642,10 @@ struct CmdDevelop : Common, MixEnvironment
ignoreException();
}
// Override SHELL with the one chosen for this environment.
// This is to make sure the system shell doesn't leak into the build environment.
setenv("SHELL", shell.data(), 1);
// 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 || !command.empty() ? Strings{std::string(baseNameOf(shell)), rcFilePath}