Large files lead to pipefail

Johannes Altmanninger aclopte at gmail.com
Wed Apr 24 05:47:33 UTC 2024


On Wed, Apr 17, 2024 at 05:05:27PM +0200, Torsten Casselt wrote:
> Hi,
> 
> we found a bug with large files resulting in pipefail. Fix is attached.
> diff --git a/src/password-store.sh b/src/password-store.sh
> --- a/src/password-store.sh
> +++ b/src/password-store.sh
> @@ -367,7 +367,7 @@
>  			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" | cut -d $'\n' -f ${selected_line})" || exit $?

Confirmed that this command sometimes leads to a pipestatus of 141 (SIGPIPE) for "tail":

	bash -c 'seq 10000 | tail -n +10 | head -1; echo pipestatus: ${PIPESTATUS[@]}'

Personally I'd use sed. It's interesting to learn that cut do this

	pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | sed -n ${selected_line}p)" || exit $?

I also wonder if pipefail really pulls its weight, maybe better to disable it

>  			[[ -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