I would like to manage the execution of related scripts and want a general method for knowing if a script had an error. The standard way to do this is to check the return code, but Stata in batch-mode always seems to return an exit status of 0 (indicating no error) even when the code it's running produces an error (at least for v13 on Windows & Linux).
$ stata-mp -b error 1
$ echo $?
0
This seems odd. Is there anyway to have Stata return a non-0 exit status? Are non-zero return codes reserved for when the Stata executable has an error rather than the script having an error? Possible work-arounds (to hopefully be avoided) could be (a) checking the log file afterward or (b) having the script capture errors and write out the return code to a file.
$ stata-mp -b error 1
$ echo $?
0
This seems odd. Is there anyway to have Stata return a non-0 exit status? Are non-zero return codes reserved for when the Stata executable has an error rather than the script having an error? Possible work-arounds (to hopefully be avoided) could be (a) checking the log file afterward or (b) having the script capture errors and write out the return code to a file.
Comment