diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-14 16:04:58 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-06-14 16:58:28 +0200 |
commit | 8446a40fbca8b092d28952edba163ed7df0be2a2 (patch) | |
tree | 0d12e2506f38e6fc0501cdccd9ff9d36c9e4fc5c | |
parent | f97cf971d813bda250edaa3757c24ef1dc986309 (diff) |
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.
-rwxr-xr-x | src/password-store.sh | 6 |
1 files changed, 4 insertions, 2 deletions
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" |