设置 Mathematica 命令行退出代码

Set Mathematica command line exit code

我是 运行 来自命令行的 Mathematica,或多或少使用这里讨论的方法:

Call a Mathematica program from the command line, with command-line args, stdin, stdout, and stderr

我只是想知道;如何控制命令行看到的退出代码?例如,我通过 Bash 脚本中的循环多次 运行 我的 Mathematica 代码,如果看到退出(失败),我想终止循环,即 return代码大于 0。也就是说,如果发生不好的事情,我想尽早终止 Mathematica 代码,并将此信息传递给调用脚本,以便我可以中止循环。我认为这一定是可能的,但我在文档中没有看到任何关于 return 代码的信息,例如退出[].

等等,我只是个笨蛋; Exit[] 的文档确实说明了以下内容:

"On most computer systems, Exit[n] can be used to pass the integer exit code n to the operating system."

https://reference.wolfram.com/language/ref/Exit.html