* Where is igawk and why doesn't @include replicate this feature?
@ 2019-09-11 11:52 Troy Kenah
2019-09-11 14:27 ` Steven Penny
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Troy Kenah @ 2019-09-11 11:52 UTC (permalink / raw)
To: cygwin
Hi All,
I have a large number of scripts that were using the the igawk script,
however I have updated my gawk to a newer release that has
obsoleted/removed the igawk script.
I used to embed @include junk.awk statements to reduce repetitive code but
this no longer works. These were files were not functions, simply code
snippets; this is the type of error I am now seeing:
gawk: get_FY2019Q1OIC.awk:28: @include "../inc/segments.awk"
gawk: get_FY2019Q1OIC.awk:28: ^ syntax error
gawk: get_FY2019Q1OIC.awk:36: fromdate=mktime("2019 09 01 00 00 00")
gawk: get_FY2019Q1OIC.awk:36: ^ syntax error
gawk: get_FY2019Q1OIC.awk:36: fromdate=mktime("2019 09 01 00 00 00")
gawk: get_FY2019Q1OIC.awk:36:
^ 0 is invalid as number of arguments for mktime
Any help would be much appreciated!
Regards,
Troy Kenah.
0416 273 135
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Where is igawk and why doesn't @include replicate this feature?
2019-09-11 11:52 Where is igawk and why doesn't @include replicate this feature? Troy Kenah
@ 2019-09-11 14:27 ` Steven Penny
2019-09-12 5:18 ` Brian Inglis
2019-09-11 18:10 ` Achim Gratz
2019-09-12 3:00 ` Kaz Kylheku
2 siblings, 1 reply; 5+ messages in thread
From: Steven Penny @ 2019-09-11 14:27 UTC (permalink / raw)
To: cygwin
On Wed, 11 Sep 2019 16:54:49, Troy Kenah wrote:
> I used to embed @include junk.awk statements to reduce repetitive code but
> this no longer works. These were files were not functions, simply code
> snippets; this is the type of error I am now seeing:
>
> gawk: get_FY2019Q1OIC.awk:28: @include "../inc/segments.awk"
> gawk: get_FY2019Q1OIC.awk:28: ^ syntax error
> gawk: get_FY2019Q1OIC.awk:36: fromdate=mktime("2019 09 01 00 00 00")
> gawk: get_FY2019Q1OIC.awk:36: ^ syntax error
> gawk: get_FY2019Q1OIC.awk:36: fromdate=mktime("2019 09 01 00 00 00")
> gawk: get_FY2019Q1OIC.awk:36:
> ^ 0 is invalid as number of arguments for mktime
Works fine here:
$ gawk --version
GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)
$ cat one.awk
function f1(n1) {
return n1 + 10
}
$ cat two.awk
@include "one.awk"
BEGIN {
print f1(20)
}
$ unset POSIXLY_CORRECT
$ gawk -f two.awk
30
Finally, I would make a suggestion. "@include" is not POSIX, so if you find
yourself relying on something like this more and more, it might be better to
switch to a proper programming language. Something like Perl, Lua or Tcl.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Where is igawk and why doesn't @include replicate this feature?
2019-09-11 11:52 Where is igawk and why doesn't @include replicate this feature? Troy Kenah
2019-09-11 14:27 ` Steven Penny
@ 2019-09-11 18:10 ` Achim Gratz
2019-09-12 3:00 ` Kaz Kylheku
2 siblings, 0 replies; 5+ messages in thread
From: Achim Gratz @ 2019-09-11 18:10 UTC (permalink / raw)
To: cygwin
Troy Kenah writes:
> I have a large number of scripts that were using the the igawk script,
> however I have updated my gawk to a newer release that has
> obsoleted/removed the igawk script.
The semantics for @include are different between igawk and "native" gawk
@include (since 4.x). The newer gawk versions treat @include statements
like they would treat the --include option on the command line. In
particular that means that each include is processed only once and you
should (only) use it to define functions.
The igawk script was removed from gawk in this commit
http://git.savannah.gnu.org/cgit/gawk.git/commit/?id=577ece63770a6c4b5ad00d6998127fb7e85b86b9
but left in the manual, so you can resurrect it either from there or
from Git:
http://git.savannah.gnu.org/cgit/gawk.git/plain/awklib/eg/prog/igawk.sh
Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Factory and User Sound Singles for Waldorf Q+, Q and microQ:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Where is igawk and why doesn't @include replicate this feature?
2019-09-11 11:52 Where is igawk and why doesn't @include replicate this feature? Troy Kenah
2019-09-11 14:27 ` Steven Penny
2019-09-11 18:10 ` Achim Gratz
@ 2019-09-12 3:00 ` Kaz Kylheku
2 siblings, 0 replies; 5+ messages in thread
From: Kaz Kylheku @ 2019-09-12 3:00 UTC (permalink / raw)
To: cygwin
On 2019-09-10 23:54, Troy Kenah wrote:
> Hi All,
>
> I have a large number of scripts that were using the the igawk script,
> however I have updated my gawk to a newer release that has
> obsoleted/removed the igawk script.
Gawk's build system stopped installing igawk over five years ago:
http://git.savannah.gnu.org/cgit/gawk.git/commit/?id=577ece63770a6c4b5ad00d6998127fb7e85b86b9
> I used to embed @include junk.awk statements to reduce repetitive code
> but
> this no longer works. These were files were not functions, simply code
> snippets; this is the type of error I am now seeing:
Clearly, the script is not exactly obsolete, since the @include facility
in
Gawk seems only to work with syntactically complete units, whereas
igawk performs blind textual inclusion.
If I were you, I'd just bring the igawk script into my code base and
continue that way. It's a tiny script that is licensed as
public domain; it doesn't carry much "technical debt" or licensing
debt.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Where is igawk and why doesn't @include replicate this feature?
2019-09-11 14:27 ` Steven Penny
@ 2019-09-12 5:18 ` Brian Inglis
0 siblings, 0 replies; 5+ messages in thread
From: Brian Inglis @ 2019-09-12 5:18 UTC (permalink / raw)
To: cygwin
On 2019-09-11 05:52, Steven Penny wrote:
> On Wed, 11 Sep 2019 16:54:49, Troy Kenah wrote:
>> I used to embed @include junk.awk statements to reduce repetitive code but
>> this no longer works. These were files were not functions, simply code
>> snippets; this is the type of error I am now seeing:
> Works fine here:
>
> Â Â $ gawk --version
> Â Â GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)
>
> Â Â $ cat one.awk
> Â Â function f1(n1) {
> Â Â Â Â Â return n1 + 10
> Â Â }
>
> Â Â $ cat two.awk
> Â Â @include "one.awk"
> Â Â BEGIN {
> Â Â Â Â Â print f1(20)
> Â Â }
>
> Â Â $ unset POSIXLY_CORRECT
> Â Â $ gawk -f two.awk
> Â Â 30
>
> Finally, I would make a suggestion. "@include" is not POSIX, so if you find
> yourself relying on something like this more and more, it might be better to
> switch to a proper programming language. Something like Perl, Lua or Tcl.
Any number of files are supported with option -f repetition as are expressions
with option -e repetition in any order.
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-09-12 3:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11 11:52 Where is igawk and why doesn't @include replicate this feature? Troy Kenah
2019-09-11 14:27 ` Steven Penny
2019-09-12 5:18 ` Brian Inglis
2019-09-11 18:10 ` Achim Gratz
2019-09-12 3:00 ` Kaz Kylheku
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).