From 0a8007498f9dba0d5feb191d16317ffa85a9e698 Mon Sep 17 00:00:00 2001 From: Daniel Fullmer Date: Sat, 19 Feb 2022 15:34:55 -0800 Subject: bash: use default PATH in FHS environments If bash is executed within an environment where PATH is not set, it uses the DEFAULT_PATH_VALUE compiled into bash to set PATH. In nixpkgs we set this to /no-such-path by default. This makes sense in a nixpkgs/NixOS environment since paths like /bin or /usr/bin should not be used. However, when bash is used inside an FHS environment, this produces results that differ from distributions which follow the FHS standard. Before this change: $ steam-run env -i /bin/bash -c 'echo $PATH' /no-such-path After this change: $ steam-run env -i /bin/bash -c 'echo $PATH' /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:. --- pkgs/shells/bash/5.1.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pkgs/shells/bash') diff --git a/pkgs/shells/bash/5.1.nix b/pkgs/shells/bash/5.1.nix index 3a11858747e..a30c9a4a507 100644 --- a/pkgs/shells/bash/5.1.nix +++ b/pkgs/shells/bash/5.1.nix @@ -10,6 +10,7 @@ , readline81 ? null , withDocs ? false , texinfo ? null +, forFHSEnv ? false }: with lib; @@ -39,8 +40,10 @@ stdenv.mkDerivation rec { NIX_CFLAGS_COMPILE = '' -DSYS_BASHRC="/etc/bashrc" -DSYS_BASH_LOGOUT="/etc/bash_logout" + '' + optionalString (!forFHSEnv) '' -DDEFAULT_PATH_VALUE="/no-such-path" -DSTANDARD_UTILS_PATH="/no-such-path" + '' + '' -DNON_INTERACTIVE_LOGIN_SHELLS -DSSH_SOURCE_BASHRC ''; -- cgit 1.4.1