Johannes Altmanninger <[email protected]> skriver:

> On Sun, Jan 16, 2022 at 05:50:28PM +0100, Marius Bakke wrote:
>> diff --git a/src/password-store.sh b/src/password-store.sh
>> index aef8d72..a6d8469 100755
>> --- a/src/password-store.sh
>> +++ b/src/password-store.sh
>> @@ -402,7 +402,13 @@ cmd_show() {
>>              else
>>                      echo "${path%\/}"
>>              fi
>> -            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
>> +            # 'tree' 2.0 and later writes JSON output on fd3 when present,
>> +            # so allocate a temporary fd and redirect file descriptor 3 to
>> +            # ensure we get the stdout in case fd 3 happens to exist.
>> +            tree -N -C -l --noreport "$PREFIX/$path" {tmp_fd}>&3- \
>
> Looks good. I wonder if there is a difference between {varname}>&3- and 3>&-
> I wasn't familiar with Bash's {varname}>&3- syntax.  It looked tricky at
> first; I guess it's just a contraction of {varname}>&3 3>&-

Actually 3>&- alone seems to work fine, and is nicer than the redirect
hack IMO.  I was worried it would close FD3 for subsequent processes,
but it appears FD 3 is only made invisible for that one command.

v3 incoming, thanks!

Attachment: signature.asc
Description: PGP signature

Reply via email to