From peiriannydd at gmail.com Sat Jan 20 00:03:25 2024 From: peiriannydd at gmail.com (Trevor Vaughan) Date: Fri, 19 Jan 2024 19:03:25 -0500 Subject: [PATCH 1/1] Add support for minimal systems without 'tree' Message-ID: In minimal environments, `tree` may not exist. This patch adds support for using `find` instead. The `tests/setup.sh` file was also modified to detect and fail if the `git` and `diff` commands were not present on the system running tests. Signed-off-by: Trevor Vaughan --- src/password-store.sh | 13 +++++++++++-- tests/t0500-find.sh | 6 +++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/password-store.sh b/src/password-store.sh index 22e818f..a3847cf 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -402,7 +402,12 @@ cmd_show() { else echo "${path%\/}" fi - tree -N -C -l --noreport "$PREFIX/$path" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors + + if hash -t tree >& /dev/null; then + tree -N -C -l --noreport "$PREFIX/$path" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors + else + find "$PREFIX/$path" -type f -name "*.gpg" -exec bash -c 'x="${0##${1}/}"; x="${x%%.gpg}"; echo "${x//\// >> }" ' {} "$PREFIX" \; + fi elif [[ -z $path ]]; then die "Error: password store is empty. Try \"pass init\"." else @@ -414,7 +419,11 @@ cmd_find() { [[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND pass-names..." IFS="," eval 'echo "Search Terms: $*"' local terms="*$(printf '%s*|*' "$@")" - tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' + if hash -t tree >& /dev/null; then + tree -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" 3>&- | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' + else + find "$PREFIX/$path" -type f -ipath "${terms%|*}" -exec bash -c 'x="${0##${1}/}"; x="${x%%.gpg}"; echo "${x//\// >> }" ' {} "$PREFIX" \; + fi } cmd_grep() { diff --git a/tests/t0500-find.sh b/tests/t0500-find.sh index 3cf6815..50d370f 100755 --- a/tests/t0500-find.sh +++ b/tests/t0500-find.sh @@ -12,7 +12,11 @@ test_expect_success 'Make sure find resolves correct files' ' "$PASS" generate Fishthings 122 && "$PASS" generate Fishies/stuff 21 && "$PASS" generate Fishies/otherstuff 1234 && - [[ $("$PASS" find fish | sed "s/^[ \`|-]*//g;s/$(printf \\x1b)\\[[0-9;]*[a-zA-Z]//g" | tr "\\n" -) == "Search Terms: fish-Fish-Fishies-otherstuff-stuff-Fishthings-" ]] + x=$("$PASS" find fish | sed "s/^[ \`|-]*//g;s/$(printf \\x1b)\\[[0-9;]*[a-zA-Z]//g" | tr "\\n" -) && + ( + [[ "$x" == "Search Terms: fish-Fish-Fishies-otherstuff-stuff-Fishthings-" ]] || + [[ "$x" == "Search Terms: fish-Fishies >> stuff-Fishies >> otherstuff-Fishthings-Fish-" ]] + ) ' test_done -- 2.39.3 From esgascoigne at gmail.com Sun Jan 28 16:17:27 2024 From: esgascoigne at gmail.com (Ethan Gascoigne) Date: Sun, 28 Jan 2024 16:17:27 +0000 Subject: Support for VISUAL text editor Message-ID: Patch to add support for VISUAL terminal editor, at the moment it only uses EDITOR (or vi if EDITOR is not set). Would be useful as I for example have VISUAL set to "micro" and EDITOR to "nano", right now pass only ever uses nano. Ethan -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-added-VISUAL-support-tries-VISUAL-then-EDITOR-then-v.patch Type: text/x-patch Size: 1872 bytes Desc: not available URL: