From 8446a40fbca8b092d28952edba163ed7df0be2a2 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 14 Jun 2018 16:04:58 +0200 Subject: show: buffer output before displaying, in case decryption fails For the line-choosing case, this is actually a big deal since we weren't passing the error code back to the user either. --- src/password-store.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/password-store.sh b/src/password-store.sh index ccc22ea..9c220eb 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -357,15 +357,17 @@ cmd_show() { [[ $err -ne 0 || ( $qrcode -eq 1 && $clip -eq 1 ) ]] && die "Usage: $PROGRAM $COMMAND [--clip[=line-number],-c[line-number]] [--qrcode[=line-number],-q[line-number]] [pass-name]" + local pass local path="$1" local passfile="$PREFIX/$path.gpg" check_sneaky_paths "$path" if [[ -f $passfile ]]; then if [[ $clip -eq 0 && $qrcode -eq 0 ]]; then - $GPG -d "${GPG_OPTS[@]}" "$passfile" || exit $? + pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile")" || exit $? + echo "$pass" else [[ $selected_line =~ ^[0-9]+$ ]] || die "Clip location '$selected_line' is not a number." - local pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +${selected_line} | head -n 1)" + pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +${selected_line} | head -n 1)" || exit $? [[ -n $pass ]] || die "There is no password to put on the clipboard at line ${selected_line}." if [[ $clip -eq 1 ]]; then clip "$pass" "$path" -- cgit v1.2.3