Skip to content

Commit d80a65d

Browse files
authored
Prevent multiple executions of nix-profile.sh (see #12805)
Add a check to ensure the script executes only once per shell. This makes bash behave the same way as fish, which checks `__ETC_PROFILE_NIX_SOURCED` both for nix.fish and nix-daemon.fish
1 parent 931f84b commit d80a65d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

scripts/nix-profile.sh.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
# Only execute this file once per shell.
12
# This file is tested by tests/installer/default.nix.
3+
if [ -n "${__ETC_PROFILE_NIX_SOURCED:-}" ]; then return; fi
4+
export __ETC_PROFILE_NIX_SOURCED=1
5+
26
if [ -n "${HOME-}" ] && [ -n "${USER-}" ]; then
37

48
# Set up the per-user profile.

0 commit comments

Comments
 (0)