Skip to content

Commit

Permalink
Remove objects before and after script is run
Browse files Browse the repository at this point in the history
  • Loading branch information
Arni Magnusson committed Mar 19, 2018
1 parent 46b793b commit a9c0183
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions R/sourceTAF.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'
#' @param script script filename.
#' @param rm whether to remove all objects from the global environment before
#' the script is run.
#' and after the script is run.
#' @param clean whether to remove the corresponding TAF directory before running
#' the script.
#' @param quiet whether to suppress messages reporting progress.
Expand Down Expand Up @@ -59,9 +59,12 @@ sourceTAF <- function(script, rm=FALSE, clean=TRUE, quiet=FALSE)
owd <- setwd(dirname(script))
on.exit(setwd(owd))
result <- try(source(basename(script)))

ok <- class(result) != "try-error"
if(!quiet)
msg(" ", script, if(ok) " done" else " failed")

if(rm)
rm(list=ls(.GlobalEnv), pos=.GlobalEnv)

invisible(ok)
}
2 changes: 1 addition & 1 deletion man/sourceTAF.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a9c0183

Please sign in to comment.