FILE.R <- tempfile(fileext = ".R")
writeLines(c("
LINENO()
LINENO()
## LINENO() respects #line directives
#line 15
LINENO()
#line 1218
cat(sprintf('invalid value %d at %s, line %d\\n',
-5, try.this.path(), LINENO()))
"), FILE.R)
# ## previously used:
#
# source(FILE.R, echo = TRUE, verbose = FALSE,
# max.deparse.length = Inf, keep.source = TRUE)
#
# ## but it echoes incorrectly with #line directives
this.path:::.source(FILE.R, echo = TRUE, verbose = FALSE,
max.deparse.length = Inf, keep.source = TRUE)
unlink(FILE.R)
Run the code above in your browser using DataLab