From e310bbf913ba068e1669c57de255cb811422fe8b Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Mon, 4 Mar 2024 07:59:32 +0100 Subject: Merge pull request #8043 from bobvanderlinden/pr-shell-env nix: develop: use SHELL from rc script (cherry picked from commit 0d55d660d5ea081630aa9606b047eb755cff1528) Change-Id: I83be6c63b282d7f01a0defa78d9e787c77f1f02d --- src/nix/develop.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nix/develop.cc b/src/nix/develop.cc index e9326cae9..07672a80a 100644 --- a/src/nix/develop.cc +++ b/src/nix/develop.cc @@ -262,7 +262,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", @@ -527,7 +526,7 @@ struct CmdDevelop : Common, MixEnvironment setEnviron(); // prevent garbage collection until shell exits - setenv("NIX_GCROOT", gcroot.data(), 1); + setenv("NIX_GCROOT", gcroot.c_str(), 1); Path shell = "bash"; @@ -570,6 +569,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.c_str(), 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} -- cgit v1.2.3