Skip to content

Commit

Permalink
on.exit(add = TRUE) is almost always the right thing to do
Browse files Browse the repository at this point in the history
Without add = TRUE, it is easy to shoot yourself in the foot when you have other `on.exit()` calls.
  • Loading branch information
yihui authored and viking committed Nov 8, 2017
1 parent 2566f5c commit 67496b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/R/yaml.load_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function(input, error.label, ...) {
}
}

if(is.character(input)) {
if (is.character(input)) {
con <- file(input, encoding = 'UTF-8')
on.exit(close(con))
on.exit(close(con), add = TRUE)
} else {
con <- input
}
Expand Down

0 comments on commit 67496b6

Please sign in to comment.