From 5878d1371f93486cc9485ab5b635774c86f14b3c Mon Sep 17 00:00:00 2001 From: Andrew Engelbrecht Date: Tue, 19 Oct 2021 22:10:05 -0400 Subject: [PATCH] trap to remove temporary log file on exit --- kaya | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kaya b/kaya index 0392ddb..d76f7b3 100755 --- a/kaya +++ b/kaya @@ -134,6 +134,7 @@ start-backup() { password="$(head -n1 "${password_file}")" log_dump="$(mktemp)" + trap 'rm -f ${log_dump}' EXIT # make the backup over a forwarded port cat << EOF | ssh -R "${remote_port}:localhost:${local_port}" "${remote_user}@${hostname}" kaya-client \ @@ -145,11 +146,9 @@ EOF # confirm that the SSH session completed if tail -1 "${log_dump}" | grep -v -e "^KAYA_SUCCESSFUL_BACKUP_MESSAGE" -e "^kaya-client: command exit code" ; then - rm "${log_dump}" echo "kaya: backup interrupted or failed to complete" >&2 exit 1 fi - rm "${log_dump}" } main() { -- 2.25.1