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: Aharon Robbins
Subject: Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?
Date: Wed, 13 May 2015 09:03:53 +0300
User-agent: Heirloom mailx 12.5 6/20/10

Hi.

> > While access to the raw argv would be nice, that's not how awk has
> > ever worked, nor is that how POSIX defines it.  Sorry.
>
> I respectfully disagree. 
>
> For the use case of loading library files from an awk program
> dynamically, this holds true, but for another reason. You cannot use a
> variable to @include files (I guess because the @include directives
> are processed before the BEGIN{}-block gets executed)

Quite correct. @include is processed during scanning and parsing.

> Gawk, however, *does* provide raw access to the ARGV array with the -E
> (or --exec) option.
>
> --exec instructs gawk to not do any processing of the command line.
> You'll get responsibility of processing anything of interest, and
> deleting the processed items from the ARGV array. 

Technically, you are correct. But in the context of standard awk,
and/or using the -f and the -i options, my statement holds. These
are definitely the more common contexts.

Also note that -E and its argument do not show up in ARGV.  Because of
this, -E does not solve the original poster's question of how to get
the full path name of the script being run.

Thanks,

Arnold



reply via email to

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