commit 9fe3cb21e1193ede695bc790a5c476b009aef895
parent 5ebe3f0a8949f4cafa2f2015fee96a6ed4bc1dce
Author: Brian Mattern <rephorm@rephorm.com>
Date: Wed, 12 Sep 2012 22:24:11 -0700
Confirm before overwriting an entry
This asks before inserting a password when one already exists at that
location (instead of just overwriting it).
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git 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