-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Initially this worked as intended but recently has ceased issuing a nonzero return code when the Stata do-file exits with error.
to try to trace out what is happening, I made just a few slight changes to your statab.sh file,
adding -echo $rc- right after the rc variable is created
commenting out the
rm "$log"
line and then adding
echo "$log"
echo $rc
so that I could examine what is happening and what may be getting missed.
When I run a properly working do-file (named "reducedForm.do"), I get what we expect:
ARE10165 /cygdrive/w/BD_Sanitation_Social/analysis(checkBatch *%) $ ./code/bin/statab.sh do code/reducedForm.do
0
reducedForm.log
0
and there is no error and the log-file concludes as we would expect.
(Note that -echo "$log"- returning reducedForm.log means (I think) that statab.sh is finding the .log file correctly.)
However, when I intentionally mess up reducedForm.do to cause an error, I get the same thing:
ARE10165 /cygdrive/w/BD_Sanitation_Social/analysis(checkBatch *%) $ ./code/bin/statab.sh do co de/reducedForm.do
0
reducedForm.log
0
Even though the .log file has an error at the end:
. boom
--Break--
r(1);
end of do-file
--Break--
r(1);
So I guess something is happening when creating the rc variable
$STATABATCH $cmd "$@" 2>&1 | tail -100 > $log.extra
rc=$?
or
if egrep --before-context=1 --max-count=1 "^r\([0-9]+\);$" "$log"
then
rc=1
fi
such that rc is not picking up the error in the log-file.
I've attached the slightly modified statab.sh file. (saved as .txt so that github will allow the attachment)