[PATCH] The pipe to a tail and then head -1 can fail due to a, pipefail., https://stackoverflow.com/questions/22464786/ignoring-bash-pipefail-for-error-code-141, Since sed is used elsewhere in the script, using sed seems simpler and more, performant.

Judd Montgomery judd at jpilot.org
Thu Jan 19 02:45:03 UTC 2023


On 1/18/23 19:43, Kjetil Torgrim Homme wrote:
> Den 18/01/2023 23:46, skreiv Judd Montgomery:
>>    From 4b547b5332110c19ebdc8802d1cd628979ade59a Mon Sep 17 00:00:00 2001
>> From: Judd Montgomery <judd at jpilot.org>
>> Date: Wed, 18 Jan 2023 17:32:56 -0500
>> Subject: [PATCH] The pipe to a tail and then head -1 can fail due to a
>>     pipefail.
>>     https://stackoverflow.com/questions/22464786/ignoring-bash-pipefail-for-error-code-141
>>     Since sed is used elsewhere in the script, using sed seems simpler and
>> more
>>     performant.
>>
>>
>> diff --git a/src/password-store.sh b/src/password-store.sh
>> index 22e818f..8ea4d65 100755
>> --- a/src/password-store.sh
>> +++ b/src/password-store.sh
>> @@ -388,7 +388,7 @@ cmd_show() {
>>                            echo "$pass" | $BASE64 -d
>>                    else
>>                            [[ $selected_line =~ ^[0-9]+$ ]] || die "Clip
>> location '$selected_line' is not a number."
>> -                       pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" |
>> tail -n +${selected_line} | head -n 1)" || exit $?
>> +                       pass=$("$GPG" -d "${GPG_OPTS[@]}" "$passfile" |
>> sed -n "${selected_line}"p)
>>                            [[ -n $pass ]] || die "There is no password to
>> put on the clipboard at line ${selected_line}."
>>                            if [[ $clip -eq 1 ]]; then
>>                                    clip "$pass" "$path"
>>
>>
>>
> I'm sorry to say your e-mail client really chewed that up and spat it
> out in mangled pieces.  those are no-break-spaces for the indentation,
> random line breaks thrown in, etc.
That is exactly what I expected to happen.  I tried to send it in HTML
first and it was rejected.
> --
> Kjetil T. Homme
> Redpill Linpro - Changing the game
>
Finding the bug and fixing it... maybe 1 hour.
Figuring out how to contribute my work upstream... maybe 4 hours...

Judd





More information about the Password-Store mailing list