summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--man/pass.16
-rwxr-xr-xsrc/password-store.sh34
2 files changed, 28 insertions, 12 deletions
diff --git a/man/pass.1 b/man/pass.1
index a124c32..0894d6d 100644
--- a/man/pass.1
+++ b/man/pass.1
@@ -98,9 +98,11 @@ it to the clipboard using
.BR xclip (1)
and then restore the clipboard after 45 seconds.
.TP
-\fBrm\fP \fIpass-name\fP
+\fBrm\fP [ \fI--recursive\fP, \fI-r\fP ] [ \fI--force\fP, \fI-f\fP ]\fI pass-name\fP
Remove the password named \fIpass-name\fP from the password store. This command is
-alternatively named \fBremove\fP.
+alternatively named \fBremove\fP or \fBdelete\fP. If \fI--recursive\fP or \fI-r\fP
+is specified, delete pass-name recursively if it is a directory. If \fI--force\fP
+or \fI-f\fP is specified, do not interactively prompt before removal.
.TP
\fBpush\fP
If the password store is a git repository, push the latest changes using
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
;;