diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2012-09-16 03:38:34 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2012-09-16 03:39:58 +0200 |
commit | 65a4751b3802ca84904385646b95ff15bae89e70 (patch) | |
tree | 40d711daecaf48581092f5e502a5a7d97465363a /src/password-store.sh | |
parent | 0a0661fbbe73e0bd6667e1b56c76c13379c42c61 (diff) | |
download | pass-65a4751b3802ca84904385646b95ff15bae89e70.tar.gz pass-65a4751b3802ca84904385646b95ff15bae89e70.tar.bz2 pass-65a4751b3802ca84904385646b95ff15bae89e70.zip |
Support recursive and forced removal.
Laurent asked for this.
Reported-by: Laurent Ghigonis <laurent@p1sec.com>
Diffstat (limited to '')
-rwxr-xr-x | src/password-store.sh | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/password-store.sh b/src/password-store.sh index a6e8fb7..0a12d67 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -46,8 +46,8 @@ Usage: $program generate [--no-symbols,-n] [--clip,-c] pass-name pass-length Generate a new password of pass-length with optionally no symbols. Optionally put it on the clipboard and clear board after 45 seconds. - $program rm pass-name - Remove existing password. + $program rm [--recursive,-r] [--force,-f] pass-name + Remove existing password or directory, optionally forcefully. $program push If the password store is a git repository, push the latest changes. $program pull @@ -306,19 +306,33 @@ case "$command" in fi ;; delete|rm|remove) + recursive="" + force="-i" + opts="$(getopt -o rf -l recursive,force -n $program -- "$@")" + err=$? + eval set -- "$opts" + while true; do case $1 in + -r|--recursive) recursive="-r"; shift ;; + -f|--force) force="-f"; shift ;; + --) shift; break ;; + esac done if [[ $# -ne 1 ]]; then - echo "Usage: $program $command pass-name" + echo "Usage: $program $command [--recursive,-r] [--force,-f] pass-name" exit 1 fi path="$1" - passfile="$PREFIX/$path.gpg" - if ! [[ -f $passfile ]]; then - echo "$path is not in the password store." - exit 1 + + passfile="$PREFIX/$path" + if ! [[ -d $passfile ]]; then + passfile="$PREFIX/$path.gpg" + if ! [[ -f $passfile ]]; then + echo "$path is not in the password store." + exit 1 + fi fi - rm -i -v "$passfile" - if [[ -d $GIT && ! -f $passfile ]]; then - git rm -f "$passfile" + rm $recursive $force -v "$passfile" + if [[ -d $GIT && ! -e $passfile ]]; then + git rm -r "$passfile" git commit -m "Removed $path from store." fi ;; |