[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
Wed Jan 18 22:46:23 UTC 2023


 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"





More information about the Password-Store mailing list