diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2012-09-13 00:50:25 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2012-09-13 00:50:25 +0200 |
commit | 59b5377ab155e0a00f57287d8b55ca5b05f0974e (patch) | |
tree | c24bd2a6986418413bfd0ebe98eb366c5755fc19 | |
parent | 2ac8b6577f806b8bd4cbc103d2837ebed68f6778 (diff) | |
download | pass-59b5377ab155e0a00f57287d8b55ca5b05f0974e.tar.gz pass-59b5377ab155e0a00f57287d8b55ca5b05f0974e.tar.bz2 pass-59b5377ab155e0a00f57287d8b55ca5b05f0974e.zip |
Be more careful about cleaning up.
-rwxr-xr-x | src/password-store.sh | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/password-store.sh b/src/password-store.sh index f9e13e4..ed86248 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -212,7 +212,9 @@ case "$command" in passfile="$PREFIX/$path.gpg" template="$program.XXXXXXXXXXXXX" - if [ -d /dev/shm -a -w /dev/shm -a -x /dev/shm ]; then + trap 'rm -rf "$tmp_dir" "$tmp_file"' INT TERM EXIT + + if [[ -d /dev/shm && -w /dev/shm && -x /dev/shm ]]; then tmp_dir="$(TMPDIR=/dev/shm mktemp -t $template -d)" else echo "Your system does not have /dev/shm, which means that it may" @@ -229,10 +231,7 @@ case "$command" in action="Added" if [[ -f $passfile ]]; then - if ! gpg -q -d -o "$tmp_file" --yes "$passfile"; then - rm -rf "$tmp_file" "$tmp_dir" - exit 1 - fi + gpg -q -d -o "$tmp_file" --yes "$passfile" || exit 1 action="Edited" fi ${EDITOR:-vi} "$tmp_file" @@ -240,7 +239,6 @@ case "$command" in echo "GPG encryption failed. Retrying." sleep 1 done - rm -rf "$tmp_file" "$tmp_dir" if [[ -d $GIT ]]; then git add "$passfile" |