summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-02-01 11:57:38 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-02-01 11:57:38 +0100
commit94ac2ba2c6baa268a64cb4e96421f6f1bf96fd96 (patch)
tree1a482ac9a98b52fb0a087b271e77a7b236d2abec /src
parentbd1cadd5620279b5ee781434b4f0731eb9ad730d (diff)
downloadpass-94ac2ba2c6baa268a64cb4e96421f6f1bf96fd96.tar.gz
pass-94ac2ba2c6baa268a64cb4e96421f6f1bf96fd96.tar.bz2
pass-94ac2ba2c6baa268a64cb4e96421f6f1bf96fd96.zip
generate: in-place should work when file is empty
Diffstat (limited to '')
-rwxr-xr-xsrc/password-store.sh2
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"