bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] exit in BEGIN without trigger END


From: Neil R. Ormos
Subject: Re: [bug-gawk] exit in BEGIN without trigger END
Date: Wed, 28 Nov 2018 11:58:07 -0600 (CST)

Peng Yu wrote:
> [Eli Zaretskii wrote:]

>> How about setting a flag in BEGIN and testing
>> it in END?  Then you could cause END do nothing
>> if BEGIN called 'exit'.

> It could be a solution but END needs to know
> this in BEGIN. It would be best if there is a
> solution that does on involve any changes in the
> code of END.

Dividing by zero in a BEGIN rule (or some other
non-END rule) will cause the program to terminate
immediately without invoking any END rules.  You
lose the ability to explicitly set the return
code.

Arnold Robbins added an abort() function to the
gawk extension library.  You can pass a parameter
to abort() to set the return code.  For details,
check the list archives for January, 2018 for a
thread with the subject "abort keyword".

Best regards,

--Neil Ormos



reply via email to

[Prev in Thread] Current Thread [Next in Thread]