From 9fe3cb21e1193ede695bc790a5c476b009aef895 Mon Sep 17 00:00:00 2001 From: Brian Mattern Date: Wed, 12 Sep 2012 22:24:11 -0700 Subject: Confirm before overwriting an entry This asks before inserting a password when one already exists at that location (instead of just overwriting it). --- src/password-store.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/password-store.sh b/src/password-store.sh index 402563c..c8a0a9f 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -184,9 +184,16 @@ case "$command" in exit 1 fi path="$1" + passfile="$PREFIX/$path.gpg" + + if [[ -e $passfile ]]; then + prompt="An entry already exists for $path. Overwrite it [y/N]? " + read -p "$prompt" yesno + [[ $yesno == "y" || $yesno == "Y" ]] || exit 1 + fi + mkdir -p -v "$PREFIX/$(dirname "$path")" - passfile="$PREFIX/$path.gpg" if [[ $ml -eq 1 ]]; then echo "Enter contents of $path and press Ctrl+D when finished:" echo -- cgit v1.2.3