Hi everybody! This is my first patch por pass. Actual find:
# pass find foo Search Terms: foo ├── bar │ └── foo ├── bar-foo ├── foo │ └── bar └── foo-bar # pass find bar Search Terms: bar ├── bar │ └── foo ├── bar-foo ├── foo │ └── bar └── foo-bar 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 users. -- :: Osiris Alejandro Gomez (OSiUX) os...@osiux.com DC4495D2 0D5DD544 FC1AF00F B308A671 9237D36C https://www.osiux.com/ https://www.gcoop.coop/
diff --git a/src/password-store.sh b/src/password-store.sh index d77ff12..a409258 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -388,10 +388,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*|*' "$@")" - 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' + 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
Description: PGP signature
_______________________________________________ Password-Store mailing list Password-Store@lists.zx2c4.com https://lists.zx2c4.com/mailman/listinfo/password-store