diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-02-01 11:57:38 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-02-01 11:57:38 +0100 |
commit | 94ac2ba2c6baa268a64cb4e96421f6f1bf96fd96 (patch) | |
tree | 1a482ac9a98b52fb0a087b271e77a7b236d2abec /src/password-store.sh | |
parent | bd1cadd5620279b5ee781434b4f0731eb9ad730d (diff) | |
download | pass-94ac2ba2c6baa268a64cb4e96421f6f1bf96fd96.tar.gz pass-94ac2ba2c6baa268a64cb4e96421f6f1bf96fd96.tar.bz2 pass-94ac2ba2c6baa268a64cb4e96421f6f1bf96fd96.zip |
generate: in-place should work when file is empty
Diffstat (limited to 'src/password-store.sh')
-rwxr-xr-x | src/password-store.sh | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/password-store.sh b/src/password-store.sh index e3cd145..e3e5659 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -519,7 +519,7 @@ cmd_generate() { $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile" "${GPG_OPTS[@]}" <<<"$pass" || die "Password encryption aborted." else local passfile_temp="${passfile}.tmp.${RANDOM}.${RANDOM}.${RANDOM}.${RANDOM}.--" - if $GPG -d "${GPG_OPTS[@]}" "$passfile" | sed $'1c \\\n'"$(sed 's/[\/&]/\\&/g' <<<"$pass")"$'\n' | $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile_temp" "${GPG_OPTS[@]}"; then + if { echo "$pass"; $GPG -d "${GPG_OPTS[@]}" "$passfile" | tail -n +2; } | $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile_temp" "${GPG_OPTS[@]}"; then mv "$passfile_temp" "$passfile" else rm -f "$passfile_temp" |