From @|mon@urb@nek @end|ng |rom R-project@org  Thu Feb 28 15:36:19 2019
From: @|mon@urb@nek @end|ng |rom R-project@org (Simon Urbanek)
Date: Thu, 28 Feb 2019 09:36:19 -0500
Subject: [Rd] Exit status of Rscript
In-Reply-To: <CAF6EP_5U1UEG+q36mcmWOGj8-fHb7foEQ2-+Wv0+wOY252Pkow@mail.gmail.com>
References: <CAF6EP_5U1UEG+q36mcmWOGj8-fHb7foEQ2-+Wv0+wOY252Pkow@mail.gmail.com>
Message-ID: <E2D7088D-5D23-41A3-AAA9-7A882FDA0965@R-project.org>

> 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
Execution halted
[1] FALSE
> sessionInfo()
R Under development (unstable) (2019-02-27 r76167)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

You may also want to check that you run what you think you do in the shell:

$ Rscript -e 'print(R.version.string); stop("foo")'; echo $?
[1] "R Under development (unstable) (2019-02-27 r76167)"
Error: foo
Execution halted
1

$ Rscript -e 'print(R.version.string); stop("foo")'; echo $?
[1] "R version 3.5.2 (2018-12-20)"
Error: foo
Execution halted
1

$ Rscript -e 'print(R.version.string); stop("foo")'; echo $?
[1] "R version 3.4.4 Patched (2018-03-19 r75535)"
Error: foo
Execution halted
1


> On Feb 28, 2019, at 7:23 AM, Michel Lang <michellang at gmail.com> wrote:
> 
> 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 didn't find this in the NEWS, so I believe this is a bug.
> 
> Best,
> Michel
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] Exit status of Rscript
Simon Urbanek