bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?


From: Andrew J. Schorr
Subject: Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?
Date: Thu, 14 May 2015 23:33:07 -0400
User-agent: Mutt/1.5.23 (2014-03-12)

On Fri, May 15, 2015 at 06:17:40AM +0300, Aharon Robbins wrote:
> You can always remove the @ignore temporarily to actually see it.

That's a fair point. :-)

> Anyway, please replace
> 
>       @code{argc-1}
> 
> with
> 
>       @code{ARGC} @minus{} 1
> 
> and then you're fine.

Hmmm, no, I don't think so: ARGC and argc have different values, since
argc is what's passed into main by the O/S, whereas ARGC is typically
smaller due to gawk's having consumed some of the arguments.

For example:

bash-4.2$ ./gawk 'BEGIN {for (i = 0; i < length(PROCINFO["argv"]); i++) print 
i, PROCINFO["argv"][i]; print ARGC, length(PROCINFO["argv"])}'
0 ./gawk
1 BEGIN {for (i = 0; i < length(PROCINFO["argv"]); i++) print i, 
PROCINFO["argv"][i]; print ARGC, length(PROCINFO["argv"])}
1 2

Are you saying it should be '@code{argc} @minus{} 1' instead
of '@code{argc-1}'?

Regards,
Andy



reply via email to

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