As Tomas pointed out, it may be helpful to read the R documentation. The error
option expects a function, so I suppose you intended something like
options(error=function() {recover(); q(status=1)})
which corresponds to calling dump.frames()
Cheers,
Simon
> On Mar 17, 2019, at 23:44, comic fans
Thanks for explanation, so recover in non-interactive session exit
with 0 is expected behavior .
dump.frames said that it always write to file (workspace , or specified file).
I have a R script run as a auto build stage, so I want to print detail
backtrace to console
(with source file, line numbe
Please refer to the documentation (?stop, ?recover, ?dump.frames). In
non-interactive use, recover() works as dump.frames(). dump.frames() is
documented not to quit R, and the examples show how to quit the R
session with a given status automatically after dump.frames(). So in
line with the d
Hello, I've noticed that Rscript didn't exit with error code if I set
options error = utils::recover in .Rprofile . for example
Rscript -e "asdf"
Error: object 'asdf' not found
No suitable frames for recover()
echo $?
0
if didn't set options in .Rprofile, Rscript exit with error code 1, is
this
> system2("Rscript", c("-e", shQuote("stop('foo')"))) == 0
Error: foo
Execution halted
[1] FALSE
> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
> system2("Rscript", c("-e", shQuote("stop('foo')"))) == 0
Error: foo
Ex
Hello,
I cannot reproduce this, R 3.5.2 on Ubuntu 18.04 LTS. sessionInfo() below.
system2("Rscript", c("-e", shQuote("stop('foo')"))) == 0
#Erro: foo
#Execução interrompida
#[1] FALSE
r <- system2("Rscript", c("-e", shQuote("stop('foo')")))
#Erro: foo
#Execução interrompida
print(r)
#[1] 1
s
Current R release (3.5.2) and devel return a 0 exit status on error,
while prior versions returned a non-zero exit status. On Linux and
MacOs, the following line returns TRUE for R-3.5.2 and R-devel, and
FALSE for R-3.5.1 and R-3.5.0:
system2("Rscript", c("-e", shQuote("stop('foo')"))) == 0
I did