bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] inside awk script check that -M/--bignum given on command


From: Neil R. Ormos
Subject: Re: [bug-gawk] inside awk script check that -M/--bignum given on command line?
Date: Mon, 8 Jan 2018 09:44:51 -0600 (CST)

Andrew J. Schorr wrote:
> address@hidden wrote:

>> [...] W.R.T. End rule order, yes, you do have to make sure that assert.awk
>> (or a theoretical abort.awk) is the first part of the whole awk program.

> Yes -- it's slightly fragile. I must confess that I personally think having an
> abort statement in the language would be a nice addition (simply because it
> would save typing and reduce code clutter), but I'm pretty sure you will
> adamantly resist this. :-) It seems that TAWK has this, and you document it in
> your O'Reilly book about sed & awk. I wonder whether it could be implemented 
> in
> an extension library. I suppose the function could simply call 'exit', and 
> that
> would eliminate the ordering fragility of using an include library. The 
> problem
> with using a library is that we lose the ability to retain the default exit
> status if none is provided to the function...

I would find an abort statement helpful.

I have long been mildly frustrated by the lack of
an abort statement in Gawk.  I understand that
it's trivial to set a flag, invoke exit, and test
the flag at the top of an END rule, assuming you
have exactly one END. For longer, non-ephemeral
programs involving extended, careful development,
the work-arounds add minimal overhead.

But for shorter programs written for an ephemeral
need, an abort statement that does not require the
inclusion of library functions or additional -f
arguments, and a specific test in the END rule,
would save a lot of extra typing and design
attention.  I write a lot of such one-off
programs, often on the command-line.

I'm intrigued by references in the Changelog to an
abort keyword that was "nuked" in 2000 "after
consultation with Brian Kernighan and Michael
Brennan".

Best regards,

--Neil Ormos



reply via email to

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