Skip to content

Commit

Permalink
restore working directory before knitting child documents; fixed yihu…
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Apr 5, 2012
1 parent 10448f3 commit 01f40a8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/output.R
Expand Up @@ -110,10 +110,11 @@ knit = function(input, output = NULL, tangle = FALSE, text = NULL) {

optk = opts_knit$get(); on.exit(opts_knit$set(optk), add = TRUE)
if (child_mode()) {
setwd(opts_knit$get('output.dir')) # always restore original working dir
## in child mode, input path needs to be adjusted
if (!is_abs_path(input))
input = file.path(input_dir(), opts_knit$get('child.path'), input)
}
} else opts_knit$set(output.dir = getwd()) # record working directory in 1st run
if (normal.input) opts_knit$set(input.dir = dirname(input)) # record input dir

if (is.null(opts_knit$get('out.format'))) {
Expand Down

0 comments on commit 01f40a8

Please sign in to comment.