fix(dotenv): expect explicit yes before loading .env file

This commit is contained in:
Marc Cornellà 2026-03-03 20:28:57 +01:00
commit 139bc2b5a1

View file

@ -37,16 +37,16 @@ source_env() {
[[ $column -eq 1 ]] || echo [[ $column -eq 1 ]] || echo
# print same-line prompt and output newline character if necessary # print same-line prompt and output newline character if necessary
echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) " echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([y]es/[N]o/[a]lways/n[e]ver) "
read -k 1 confirmation read -k 1 confirmation
[[ "$confirmation" = $'\n' ]] || echo [[ "$confirmation" = $'\n' ]] || echo
# check input # check input
case "$confirmation" in case "$confirmation" in
[nN]) return ;; [yY]) ;;
[aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;; [aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;;
[eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;; [eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;;
*) ;; # interpret anything else as a yes *) return ;; # interpret anything else as a no
esac esac
fi fi
fi fi