[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] exit in BEGIN without trigger END
From: |
arnold |
Subject: |
Re: [bug-gawk] exit in BEGIN without trigger END |
Date: |
Wed, 28 Nov 2018 11:41:09 -0700 |
User-agent: |
Heirloom mailx 12.4 7/29/08 |
Peng Yu <address@hidden> wrote:
> Hi,
>
> I see the text from the manual below.
>
> """
> When an exit statement is executed from a BEGIN rule, the program
> stops processing everything immediately. No input records are read.
> However, if an END rule is present, as part of executing the exit
> statement, the END rule is executed (see BEGIN/END). If exit is used
> in the body of an END rule, it causes the program to stop immediately.
> """
>
> I am not sure this is necessarily the best default behavior.
Given that this behavior is over 30 years old, it's not going to change.
> There are
> cases in which users may want an `exit` from BEGIN not to trigger END.
> Is there a good way to do so in awk? Thanks.
As others have answered, you either code around it, or use the
abort extension in gawkextlib (or divide by zero).
Arnold