Skip to content

Commit

Permalink
fixed on_exit bug
Browse files Browse the repository at this point in the history
  • Loading branch information
goozbach committed Jan 23, 2013
1 parent f01ab83 commit f94982c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bin/sample_app.sh
Expand Up @@ -30,7 +30,7 @@ log_info "this is a log4bats function (https://github.com/goozbach/log4bats)"
# create a tempfile
log_info "creating temp file"
TMPFILE=$(mktemp /tmp/${0##*/}-XXXXXXX)
add_on_exit 'rm -rf ${TMPFILE}'
add_on_exit "rm -rf ${TMPFILE}"

# this command will fail thanks to stringent.sh
log_info "attempting to overwrite tmp file, this should fail"
Expand Down
3 changes: 1 addition & 2 deletions src/lib/20-on_exit
Expand Up @@ -2,7 +2,6 @@
#sig term/quit handler to umount what we've mounted
# take from: http://www.linuxjournal.com/content/use-bash-trap-statement-cleanup-temporary-files
declare -a on_exit_items
on_exit_items=''
function on_exit()
{
for i in "${on_exit_items[@]}"
Expand All @@ -17,7 +16,7 @@ function add_on_exit()
local n=${#on_exit_items[*]}
on_exit_items[$n]="$*"
if [[ $n -eq 0 ]]; then
log_trace "add_on_exit called, setting on_exit trap"
log_debug "add_on_exit called, setting on_exit trap"
trap on_exit EXIT
fi
}
Expand Down

0 comments on commit f94982c

Please sign in to comment.