diff options
author | Brian Mattern <rephorm@rephorm.com> | 2012-09-12 22:24:11 -0700 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2012-09-13 07:50:20 +0200 |
commit | 9fe3cb21e1193ede695bc790a5c476b009aef895 (patch) | |
tree | 378623d2d1af2d1ab32398384564124b654ad1fe /src/password-store.sh | |
parent | 5ebe3f0a8949f4cafa2f2015fee96a6ed4bc1dce (diff) | |
download | pass-9fe3cb21e1193ede695bc790a5c476b009aef895.tar.gz pass-9fe3cb21e1193ede695bc790a5c476b009aef895.tar.bz2 pass-9fe3cb21e1193ede695bc790a5c476b009aef895.zip |
Confirm before overwriting an entry
This asks before inserting a password when one already exists at that
location (instead of just overwriting it).
Diffstat (limited to '')
-rwxr-xr-x | src/password-store.sh | 9 |
1 files changed, 8 insertions, 1 deletions
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 |