From e4d479a3fd695ced2cf7f1e9bdf6f8c3a4ad51ed Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 18 Apr 2014 13:25:58 +0200 Subject: reencrypt: cleaner temp file declaration --- src/password-store.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/password-store.sh b/src/password-store.sh index 3868600..eb98fad 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -88,17 +88,17 @@ reencrypt_path() { local passfile local passfile_dir local passfile_display - local fake_uniqueness_safety + local passfile_temp local prev_gpg_recipients local gpg_keys local current_keys find "$1" -iname '*.gpg' | while read -r passfile; do - fake_uniqueness_safety="$RANDOM" passfile_dir="${passfile%/*}" passfile_dir="${passfile_dir#$PREFIX}" passfile_dir="${passfile_dir#/}" passfile_display="${passfile#$PREFIX/}" passfile_display="${passfile_display%.gpg}" + passfile_temp="${passfile}.tmp.${RANDOM}.${RANDOM}.${RANDOM}.${RANDOM}.--" set_gpg_recipients "$passfile_dir" [[ $prev_gpg_recipients != "${GPG_RECIPIENTS[@]}" ]] && @@ -107,8 +107,8 @@ reencrypt_path() { if [[ $gpg_keys != "$current_keys" ]]; then echo "$passfile_display: reencrypting to ${gpg_keys//$'\n'/ }" - $GPG -d $GPG_OPTS "$passfile" | $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile.new.$fake_uniqueness_safety" $GPG_OPTS && - mv "$passfile.new.$fake_uniqueness_safety" "$passfile" || rm -f "$passfile.new.$fake_uniqueness_safety" + $GPG -d $GPG_OPTS "$passfile" | $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile_temp" $GPG_OPTS && + mv "$passfile_temp" "$passfile" || rm -f "$passfile_temp" fi prev_gpg_recipients="${GPG_RECIPIENTS[@]}" -- cgit v1.2.3