From e178ae39b41e554722c205d107a664dced1761b9 Mon Sep 17 00:00:00 2001 From: Mazin Ahmed Date: Wed, 12 Feb 2020 20:51:40 +0400 Subject: [PATCH] dotenv: prompt before executing dotenv file (#8606) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/dotenv/dotenv.plugin.zsh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index 89763d0ee..d4a6db8f8 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -1,5 +1,12 @@ source_env() { if [[ -f $ZSH_DOTENV_FILE ]]; then + # confirm before sourcing .env file + local confirmation + echo -n "dotenv: source '$ZSH_DOTENV_FILE' file in the directory? (Y/n) " + if read -k 1 confirmation && [[ $confirmation = [nN] ]]; then + return + fi + # test .env syntax zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2