nix-shell: add bashInteractive to the start of the PATH, set SHELL

Tools which re-exec `$SHELL` or `$0` or `basename $SHELL` or even just
`bash` will otherwise  get the non-interactive bash, providing a
broken shell for the same reasons described in
https://github.com/NixOS/nixpkgs/issues/27493.

Extends c94f3d5575
This commit is contained in:
Graham Christensen 2018-09-27 12:40:19 -04:00
parent 9750430003
commit f11acbaf17
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C

View file

@ -417,16 +417,20 @@ void mainWrapped(int argc, char * * argv)
"dontAddDisableDepTrack=1; " "dontAddDisableDepTrack=1; "
"[ -e $stdenv/setup ] && source $stdenv/setup; " "[ -e $stdenv/setup ] && source $stdenv/setup; "
"%3%" "%3%"
"PATH=\"%4%:$PATH\"; "
"SHELL=%5%; "
"set +e; " "set +e; "
R"s([ -n "$PS1" ] && PS1='\n\[\033[1;32m\][nix-shell:\w]\$\[\033[0m\] '; )s" R"s([ -n "$PS1" ] && PS1='\n\[\033[1;32m\][nix-shell:\w]\$\[\033[0m\] '; )s"
"if [ \"$(type -t runHook)\" = function ]; then runHook shellHook; fi; " "if [ \"$(type -t runHook)\" = function ]; then runHook shellHook; fi; "
"unset NIX_ENFORCE_PURITY; " "unset NIX_ENFORCE_PURITY; "
"shopt -u nullglob; " "shopt -u nullglob; "
"unset TZ; %4%" "unset TZ; %6%"
"%5%", "%7%",
(Path) tmpDir, (Path) tmpDir,
(pure ? "" : "p=$PATH; "), (pure ? "" : "p=$PATH; "),
(pure ? "" : "PATH=$PATH:$p; unset p; "), (pure ? "" : "PATH=$PATH:$p; unset p; "),
dirOf(shell),
shell,
(getenv("TZ") ? (string("export TZ='") + getenv("TZ") + "'; ") : ""), (getenv("TZ") ? (string("export TZ='") + getenv("TZ") + "'; ") : ""),
envCommand)); envCommand));