| Deutsch English Français Italiano |
|
<vgl1al$369hb$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Ruvim <ruvim.pinka@gmail.com>
Newsgroups: comp.lang.forth
Subject: Re: bye with exit status
Date: Fri, 8 Nov 2024 16:48:21 +0400
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <vgl1al$369hb$2@dont-email.me>
References: <vgfmfe$22uop$1@dont-email.me> <vgg6q4$26lgs$1@dont-email.me>
<4d5b92710816ddfe2dbbb04a2177b40b@www.novabbs.com>
<c52c3b51c000c9139d938079e3cfe988@www.novabbs.com>
<2024Nov8.092913@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 08 Nov 2024 13:48:22 +0100 (CET)
Injection-Info: dont-email.me; posting-host="e737efc88dec1dd6103f16e7236b5230";
logging-data="3352107"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189ejjOcPp91ImsmO77TsUq"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:9mwYTTkV37qZDFwmgXh63o8jsYw=
Content-Language: en-US
In-Reply-To: <2024Nov8.092913@mips.complang.tuwien.ac.at>
Bytes: 2983
On 2024-11-08 12:29, Anton Ertl wrote:
> mhx@iae.nl (mhx) writes:
>> Same as remarked by minforth: there is a exit-handler chain in
>> which the user can plug arbitrary routines.
>
> In Gforth BYE is a deferred word, with the intention that it can be
> extended with cleanup actions.
>
> The disadvantage of this approach in connection with the non-0 exit is
> that we probably also want to do the same cleanup in those cases. The
> best way to deal with that is probably the "EXIT-CODE !" approach.
I think, this variable, if it is required, should be internal.
For example:
variable _system-exit-status 0 _system-exit-status !
: kernel-bye ( -- never )
... \ other actions
_system-exit-status @ (bye)
;
defer bye ' kernel-bye is bye
: bye-with-status ( n -- never )
_system-exit-status ! bye
;
Thus, the old interface is not changed. And `bye-with-status` also does
the same cleanup sequence (if any).
> Concerning the usual discussion about the name: I find that the system
> is left in the error case with an uncaught THROW in script-execution
> mode; in that case an exit code of 1 is returned by Gforth, so it's
> not sufficient for communicating more than a binary result to the
> calling script. But I have not used non-binary exit codes for
> non-Forth programs, either, and I do quite a bit of shell scripting.
Does it mean that "bye" and "bye-failure" is enough?
>
> In any case, while we have (BYE), I don't use it in application
> programs.
As an example, when a script is used in Make, it is important to return
nonzero exit status on error.
Sometimes people ask about that, for example:
<https://stackoverflow.com/questions/71616920/how-can-i-exit-forth-with-a-non-zero-exit-status>
--
Ruvim