Skip to content

Commit

Permalink
Only load legacy ~/.direnvrc if no other direnvrc loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil committed Oct 3, 2022
1 parent ce1c286 commit 3f6363d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion stdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1387,16 +1387,21 @@ __main__() {
done
done

# By default load the legacy ~/.direnvrc
local load_legacy=1

# load global direnvrc's if present
for direnv_config_dir in "${direnv_config_dirs[@]}"; do
if [[ -f $direnv_config_dir/direnvrc ]]; then
# shellcheck disable=SC1090,SC1091
source "$direnv_config_dir/direnvrc" >&2
# Don't load legacy ~/.direnvrc if a new-style direnvrc exists
load_legacy=
fi
done

# Legacy .direnvrc
if [[ -f $HOME/.direnvrc ]]; then
if [[ -n "$load_legacy" && -f $HOME/.direnvrc ]]; then
# shellcheck disable=SC1090,SC1091
source "$HOME/.direnvrc" >&2
fi
Expand Down

0 comments on commit 3f6363d

Please sign in to comment.