14

GNU awk manual on nextfile reads:

NOTE: For many years, nextfile was a common extension. In September 2012, it was accepted for inclusion into the POSIX standard. See the Austin Group website.

Likewise, mawk manual says:

Nextfile is a gawk extension (also implemented by BWK awk), is not yet part of the POSIX standard (as of October 2012), although it has been accepted for the next revision of the standard.

What confuses me is that there is no mention of nextfile in the latest POSIX specification, from 2018.

Following the link to the Austin Group, you find that the issue was resolved in 2012 (with even a final accepted text), but only applied in 2020(!).

All in all, does it mean nextfile is an awk's feature specified by POSIX? Or will it only be so in a future POSIX version?

(For practical purposes, nextfile is also to be found in BSD awk.)

Two more statements are in the same situation as nextfile: fflush and delete (delete is already specified, but is to be expanded so as to be able to delete an entire array).

Quasímodo
  • 18,865
  • 4
  • 36
  • 73
  • 3
    As you can see, that bug is targetted for issue8, not released yet. Issue 7 was released in 2008, there have been a few newer editions of issue 7, latest in 2018, but those are technical corrigenda, they don't bring new features. – Stéphane Chazelas May 25 '20 at 20:18
  • 1
    @StéphaneChazelas Correct, Issue 8 is not yet complete. We are currently working on the gettext inclusion and then need to upgrade the include files for c2x. The current planning is that Issue 8 will be ready next year. – schily May 25 '20 at 20:23

2 Answers2

15

You'll see that bug 607 is targetted for Issue 8, not released yet (see the issue8 Tags).

Issue 7 was released in 2008, there have been a few newer editions of issue 7, latest in 2018, but those are technical corrigenda, they don't bring new features.

nextfile is not only a new feature but also breaks backward compatibility as awk '{nextfile = 1}' and awk '{nextfile}' are valid awk invocations which in the current POSIX version set and retrieve the value of a nextfile variable respectively, so it could possibly not be added as part of a technical corrigendum.

What could be added (and probably should have) in a TC is to tell people that nextfile is a word reserved for future use so that people should not use it in their variable or function names, as a script that does awk '{nextfile = 1}', though perfectly standard, does not work in many awk implementations (that's not limited to nextfile btw).

You can check a HTML rendition of the awk part of the 2018 edition of Issue 7 of the Single UNIX Specification at https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/awk.html (note the .2018edition part), though note that even though it is published by the Opengroup, the HTML version has no value of standard, only the PDF does (you need to register with them to get access to it).

They're meant to be equivalent, though there have been several bugs in the conversion to HTML in the past which have caused sections to be missing (though they're generally fixed quickly when spotted), so when in doubt, best is to check the PDF.

11

POSIX standardisation can be seen as two distinct efforts:

  • Bug fixing that does not affect interfaces, this is released as so called technical corrigendum. The current Issue 7 standard is basically from 2008 and the 2018 release is TC2.

  • New features that affect interfaces. This requires a new major version of the standard.

The awk issue if marked as Issue 8 for named reasons and we are currently working on finalizing the Issue 8 standard that is expected to be ready in 2021.

schily
  • 19,173
  • 6
    Why the downvotes? – Stéphane Chazelas May 25 '20 at 20:40
  • 1
    @StéphaneChazelas all my answers are downvoted by downvoting trolls. This is not related to content... – schily May 25 '20 at 20:53
  • @schily, many of your answers are also tangential or totally irrelevant to the questions there written under, so that may also be why they get downvotes. I don't see that problem here, though. – ilkkachu Jun 18 '20 at 21:26
  • @ilkkachu I usually give answers that in addition to the expected answer explain the background or the cause. If you don't understand this, there may be a problem at your side...so are you the downvoter or are you polite and rather write comments? If you don't understand why a particular answer correctly explains the background, you should write a useful comment that allows to make the wording better. – schily Jun 19 '20 at 06:59
  • @schily, I downvote the posts I find unclear or not useful, as I expect everyone else to also do. I also comment if I have the time and think it's useful to do so. If you want to know exactly what everyone votes, I think you'll have to ask SE about it. I think the system is supposed to keep the votes pretty much anonymous. – ilkkachu Jun 19 '20 at 08:32