[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:29:58 UTC 2023


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"



More information about the Password-Store mailing list