[prev in list] [next in list] [prev in thread] [next in thread]
List: password-store
Subject: PATCH: add -n or -nontree option in find
From: OSiUX <xuiso () osiux ! com>
Date: 2019-03-25 14:36:32
Message-ID: 20190325143339.qhz4d6wqjhiar7ds () localhost
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Hi everybody! This is my first patch por pass.
Adding -n or --notree:
# pass find foo -n
Search Terms: foo
bar-foo
bar/foo
foo-bar
foo/bar
# pass find bar -notree
Search Terms: bar
bar-foo
bar/foo
foo-bar
foo/bar
Quick help:
# pass find
Usage: pass find [--notree,-n] pass-names...
I hope it will be useful for other console ninja users.
--
::
Osiris Alejandro Gomez (OSiUX) osiux@osiux.com
DC4495D2 0D5DD544 FC1AF00F B308A671 9237D36C
https://www.osiux.com/ https://www.gcoop.coop/
["pass-find-notree-option.patch" (text/x-diff)]
diff --git a/src/password-store.sh b/src/password-store.sh
index 284eabf..0dc753b 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -408,10 +408,35 @@ cmd_show() {
}
cmd_find() {
- [[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..."
+ local opts notree=0
+ opts="$($GETOPT -o n -l notree -n "$PROGRAM" -- "$@")"
+ local err=$?
+ eval set -- "$opts"
+ while true; do case $1 in
+ -n|--notree) notree="1"; shift ;;
+ --) shift; break ;;
+ esac done
+ [[ $# -ne 1 ]] && die "Usage: $PROGRAM $COMMAND [--notree,-n] pass-names..."
IFS="," eval 'echo "Search Terms: $*"'
local terms="*$(printf '%s*|*' "$@")"
+ local f
+ local c
+ tmpdir #Defines $SECURE_TMPDIR
+ local tmp_file=$(mktemp -u "$SECURE_TMPDIR/XXXXXX")
+
+ if [[ $notree -eq 0 ]]
+ then
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' + else
+ c=$(echo "$PREFIX" | wc -c)
+ let c++
+ find "$PREFIX" -follow -type d -iname "*${@}*" 2>/dev/null | while read f
+ do
+ find "$f" -follow -type f -iname '*.gpg' 2>/dev/null
+ done > "$tmp_file"
+ find "$PREFIX" -follow -type f -iname "*${@}*.gpg" 2>/dev/null >> "$tmp_file"
+ sort -u "$tmp_file" | sed 's/.gpg//g' | cut -c $c- && rm -f "$tmp_file"
+ fi
}
cmd_grep() {
["signature.asc" (application/pgp-signature)]
_______________________________________________
Password-Store mailing list
Password-Store@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/password-store
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic