e178ae39b41e554722c205d107a664dced1761b9

Author
Mazin Ahmed <mazen160@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

dotenv: prompt before executing dotenv file (#8606)

Co-authored-by: Marc Cornellà <marc.cornella@live.com>

Diff

 1diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh
 2index 89763d0ee37ac03b98eaf3412f6e965700fadbc4..d4a6db8f842c3856ad5424c578b4bfc4dd64dd7b 100644
 3--- a/plugins/dotenv/dotenv.plugin.zsh
 4+++ b/plugins/dotenv/dotenv.plugin.zsh
 5@@ -1,5 +1,12 @@
 6 source_env() {
 7   if [[ -f $ZSH_DOTENV_FILE ]]; then
 8+    # confirm before sourcing .env file
 9+    local confirmation
10+    echo -n "dotenv: source '$ZSH_DOTENV_FILE' file in the directory? (Y/n) "
11+    if read -k 1 confirmation && [[ $confirmation = [nN] ]]; then
12+      return
13+    fi
14+
15     # test .env syntax
16     zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
17