[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] exit in BEGIN without trigger END
From: |
Eli Zaretskii |
Subject: |
Re: [bug-gawk] exit in BEGIN without trigger END |
Date: |
Wed, 28 Nov 2018 19:02:22 +0200 |
> From: Peng Yu <address@hidden>
> Date: Wed, 28 Nov 2018 10:45:44 -0600
>
> 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. 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.
How about setting a flag in BEGIN and testing it in END? Then you
could cause END do nothing if BEGIN called 'exit'.