summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2014-04-18 12:38:52 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2014-04-18 12:38:52 +0200
commit0f0483f789e4819b029cf2f9d8168a6172da4d92 (patch)
tree18822a6ea497e2fcd000f482346e9e2753b818e3 /src
parent04ff6261ca172aceb09bad926da68c41ba17b78e (diff)
downloadpass-0f0483f789e4819b029cf2f9d8168a6172da4d92.tar.gz
pass-0f0483f789e4819b029cf2f9d8168a6172da4d92.tar.bz2
pass-0f0483f789e4819b029cf2f9d8168a6172da4d92.zip
init: allow deinitialization
Diffstat (limited to '')
-rwxr-xr-xsrc/password-store.sh16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index 0aa5787..fe21e19 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -263,8 +263,22 @@ cmd_init() {
fi
fi
- mkdir -v -p "$PREFIX/$id_path"
local gpg_id="$PREFIX/$id_path/.gpg-id"
+
+ if [[ $# -eq 1 && -z $1 ]]; then
+ if [[ ! -f "$gpg_id" ]]; then
+ echo "Error: $gpg_id does not exist and so cannot be removed."
+ exit 1
+ fi
+ rm -v -f "$gpg_id" || exit 1
+ if [[ -d $GIT_DIR ]]; then
+ git rm -qr "$gpg_id"
+ git_commit "Deinitialized ${gpg_id}."
+ fi
+ exit 0
+ fi
+
+ mkdir -v -p "$PREFIX/$id_path"
printf "%s\n" "$@" > "$gpg_id"
local id_print="$(printf "%s, " "$@")"
echo "Password store initialized for ${id_print%, }"