Skip to content

Commit

Permalink
Ignore non-printable characters in calls to tree
Browse files Browse the repository at this point in the history
In MacOS Catalina, pass fails on accents with 'sed: RE error: illegal byte sequence'.
  • Loading branch information
remilapeyre committed Jul 29, 2020
1 parent 06f4999 commit 3ca96e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/password-store.sh
Expand Up @@ -400,7 +400,7 @@ cmd_show() {
else
echo "${path%\/}"
fi
tree -C -l --noreport "$PREFIX/$path" | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors
tree -N -C -l --noreport "$PREFIX/$path" | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors
elif [[ -z $path ]]; then
die "Error: password store is empty. Try \"pass init\"."
else
Expand All @@ -412,7 +412,7 @@ cmd_find() {
[[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND 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 -N -C -l --noreport -P "${terms%|*}" --prune --matchdirs --ignore-case "$PREFIX" | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g'
}

cmd_grep() {
Expand Down
5 changes: 5 additions & 0 deletions tests/t0020-show-tests.sh
Expand Up @@ -15,6 +15,11 @@ test_expect_success 'Test "show" command with spaces' '
[[ $("$PASS" show "I am a cred with lots of spaces") == "BLAH!!" ]]
'

test_expect_success 'Test "show" command with unicode' '
"$PASS" generate 🏠 &&
"$PASS" show | grep -q '🏠'
'

test_expect_success 'Test "show" of nonexistant password' '
test_must_fail "$PASS" show cred2
'
Expand Down

0 comments on commit 3ca96e0

Please sign in to comment.