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 03:13:47 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Hello Ed.

> > With |gawk|, |nextfile| is useful inside a |BEGINFILE| rule to skip 
> > over a file that would otherwise cause |gawk| to exit with a fatal 
> > error. In this case, **|ENDFILE| rules are not executed**. 

Read that a little closer.  In the case where gawk would normally
exit with an error, ENDFILE is skipped.

$ ./gawk 'BEGINFILE{print "a"; nextfile} ENDFILE{print "b"}' /no/such/file
a

The ENDFILE is not executed.

I think I need to fix this sentence, in the previous paragraph:

| In @command{gawk}, execution of @code{nextfile} causes additional things
| to happen: any @code{ENDFILE} rules are executed if @command{gawk} is
| not currently in an @code{END} or @code{BEGINFILE} rule,

to remove the BEGINFILE rule bit.

Thanks.

Arnold



reply via email to

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