如何以非零退出状态退出 Forth?
我想以非零退出状态退出 Forth 程序(使用 Gforth 0.7.3)。
我已经尝试过了:
1 bye
但是 1 没有被解释为 bye
的参数(而且我也没想到这会起作用;我在文档中找不到 bye 的任何提示
将接受一个参数)。
请注意,我不想触发异常,因为这也会打印错误消息(除非有办法从 Forth 程序本身中抑制异常的错误消息)。
那么,如何将 Forth 程序退出回托管环境/操作系统并提供非零退出状态? (基本上,我正在寻找相当于 return EXIT_FAILURE; // from main()
(C) 或 exit(EXIT_FAILURE);
(C) 或 System.exit(1);
(Java)。)
I would like to exit a Forth program (using Gforth 0.7.3) with a non-zero exit status.
I've tried:
1 bye
But the 1 is not interpreted as an argument to bye
(and I didn't expect this to work anyway; I couldn't find any hint in the documentation that bye
would accept an argument).
Note that I do not want to trigger an exception, as that also prints an error message (unless there is a way to suppress the error message of the exception from within the Forth program itself).
So, how do I exit a Forth program back to the hosted environment/OS providing a non-zero exit status?
(Basically, I'm looking for the equivalent of return EXIT_FAILURE; // from main()
(C) or exit(EXIT_FAILURE);
(C) or System.exit(1);
(Java).)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Gforth 中,内部字
(bye) ( n -- )
可用于将退出状态返回给操作系统。例如,Bash 中的以下命令:
打印“123”。
一般来说,返回非零退出状态的方法尚未标准化。
In Gforth, the internal word
(bye) ( n -- )
can be used to return the exit status to the OS.For example, the following command in Bash:
prints "123".
In general, a method to return a non-zero exit status is not standardized yet.