Fix early removal of rc-file for nix-shell
BASH_ENV causes all non-interactive shells called via eg. /etc/bashrc to remove the rc-file before the main shell gets to run it. Completion scripts will often do this. Fixes #976. Adapted from and fixes #1034.
This commit is contained in:
parent
312bab008d
commit
a5f2750ebb
1 changed files with 0 additions and 2 deletions
|
@ -410,7 +410,6 @@ int main(int argc, char ** argv)
|
||||||
auto rcfile = (Path) tmpDir + "/rc";
|
auto rcfile = (Path) tmpDir + "/rc";
|
||||||
writeFile(rcfile, (format(
|
writeFile(rcfile, (format(
|
||||||
"rm -rf '%1%'; "
|
"rm -rf '%1%'; "
|
||||||
"unset BASH_ENV; "
|
|
||||||
"[ -n \"$PS1\" ] && [ -e ~/.bashrc ] && source ~/.bashrc; "
|
"[ -n \"$PS1\" ] && [ -e ~/.bashrc ] && source ~/.bashrc; "
|
||||||
"%2%"
|
"%2%"
|
||||||
"dontAddDisableDepTrack=1; "
|
"dontAddDisableDepTrack=1; "
|
||||||
|
@ -425,7 +424,6 @@ int main(int argc, char ** argv)
|
||||||
"unset TZ; %4%"
|
"unset TZ; %4%"
|
||||||
"%5%"
|
"%5%"
|
||||||
) % (Path) tmpDir % (pure ? "" : "p=$PATH") % (pure ? "" : "PATH=$PATH:$p; unset p; ") % (getenv("TZ") ? (string("export TZ='") + getenv("TZ") + "'; ") : "") % envCommand).str());
|
) % (Path) tmpDir % (pure ? "" : "p=$PATH") % (pure ? "" : "PATH=$PATH:$p; unset p; ") % (getenv("TZ") ? (string("export TZ='") + getenv("TZ") + "'; ") : "") % envCommand).str());
|
||||||
setenv("BASH_ENV", rcfile.c_str(), 1);
|
|
||||||
if (interactive)
|
if (interactive)
|
||||||
execlp(getEnv("NIX_BUILD_SHELL", "bash").c_str(), "bash", "--rcfile", rcfile.c_str(), NULL);
|
execlp(getEnv("NIX_BUILD_SHELL", "bash").c_str(), "bash", "--rcfile", rcfile.c_str(), NULL);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue