FILE <- tempfile(fileext = ".R")
writeLines(c(
"LINENO()",
"LINENO()",
"## LINENO() respects #line directives",
"#line 1218",
"LINENO()"
), FILE)
# ## previously used:
#
# source(FILE, echo = TRUE, verbose = FALSE,
# max.deparse.length = Inf, keep.source = TRUE)
#
# ## but it echoes incorrectly with #line directives.
# ## source2() echoes correctly!
this.path:::source2(FILE, echo = TRUE, verbose = FALSE,
max.deparse.length = Inf, keep.source = TRUE)
unlink(FILE)
Run the code above in your browser using DataLab