---
I know that this has been discussed in the past; apologies if it's inappropriate to bring it up again. I believe this patch is an improvement over previous iterations, as it does not duplicate the call to tree (or introduce a call to find). I'm not sure if $PREFIX should be escaped (how?) in the regular expression -- open for ideas.

 src/password-store.sh | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index 77f3eda..ce8e14d 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -409,10 +409,19 @@ cmd_show() {
 }
cmd_find() {
-       [[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..."
+       local opts extra_args=""
+       opts="$($GETOPT -o f -l fullpath -n "$PROGRAM" -- "$@")"
+       local err=$?
+       eval set -- "$opts"
+       while true; do case $1 in
+               -f|--fullpath) extra_args="$extra_args -Ffi"; shift ;;
+               --) shift; break ;;
+       esac done
+
+       [[ $err -ne 0 || $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND 
[--fullpath,-f] pass-names..."
        IFS="," eval 'echo "Search Terms: $*"'
        local terms="*$(printf '%s*|*' "$@")"
-       tree -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case 
"$PREFIX" | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g'
+       tree -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case $extra_args 
"$PREFIX" | tail -n +2 | sed -E -e 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' -e 
"s@^$PREFIX/?@@" -e '/\/$/d'
 }
cmd_grep() {
--
2.21.1

Reply via email to