bug-gawk
[Top][All Lists]
Advanced

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

Re: Should nextfile in BEGINFILE skip ENDFILE?


From: arnold
Subject: Re: Should nextfile in BEGINFILE skip ENDFILE?
Date: Sun, 15 Nov 2020 21:08:08 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Manuel Collado <mcollado2011@gmail.com> wrote:

> I think there should be an analogy between BEGIN/exit/END and 
> BEGINFILE/nextfile/ENDFILE. If 'exit' jumps to execute the END block, 
> then 'nextfile' should jump to execute the ENDFILE block.

This is true when processing a regular file.

> Note that the ENDFILE clause is a good place for user code that handles 
> nonfatal file errors. Skipping the ENDFILE rule prevents the user for 
> handling errors his own way.

We're talking about handling fatal errors!  If the file doesn't
exist or is a directory, for example, the ENDFILE would never be reached.
This is why you have an opportunity to handle things in BEGINFILE.

Arnold



reply via email to

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