How to get an Rscript to return a status code in non-interactive bash mode
问题 I am trying to get the status code out of an Rscript run in an non-interactive way in the form of a bash script. This step is part of larger data processing cycle that involves db2 scripts among other things. So I have the following contents in a script sample.sh: Rscript --verbose --no-restore --no-save /home/R/scripts/sample.r >> sample.rout when this sample.sh is run it always returns a status code of 0, irrespective of if the sample.r script run fully or error out in an intermediate step.