summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kreutz <mail@skreutz.com>2022-10-23 11:50:40 +0200
committerStefan Kreutz <mail@skreutz.com>2022-10-23 11:50:40 +0200
commit640b3076139de726cec73cb66cea637e010ed9e9 (patch)
tree06937a11ee421e613fadd4d745bc1f6a4b8fc2e7
parent8c8b89fa139a0d6c4c4ece8094bd1ac5c7f76243 (diff)
downloadshellpass-640b3076139de726cec73cb66cea637e010ed9e9.tar
Fix removal of temporary plain text file
Overwrite temporary plain text file on happy path. Previously, the file was only overwritten when the trap executed.
-rwxr-xr-xshellpass.ksh4
1 files changed, 2 insertions, 2 deletions
diff --git a/shellpass.ksh b/shellpass.ksh
index c56b9b3..084be0d 100755
--- a/shellpass.ksh
+++ b/shellpass.ksh
@@ -81,7 +81,7 @@ function edit {
umask 077
plaintext="$( mktemp -t )"
- trap 'rm -f "$plaintext"' EXIT ERR INT
+ trap 'rm -fP "$plaintext"' EXIT ERR INT
encrypted="$( mktemp -t )"
trap 'rm -fP "$plaintext" "$encrypted"' EXIT ERR INT
@@ -98,7 +98,7 @@ function edit {
NEXINIT="set backup=" /usr/bin/vi "$plaintext"
gpg --quiet --encrypt --recipient "$gpg_id" --output - <"$plaintext" >"$encrypted"
- rm "$plaintext"
+ rm -P "$plaintext"
mv "$encrypted" "$file"
}
Generated by cgit. See skreutz.com for my tech blog and contact information.