bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] enhancement: environment variable AWKSCRIPT?


From: Wolfgang Laun
Subject: Re: [bug-gawk] enhancement: environment variable AWKSCRIPT?
Date: Thu, 24 May 2018 13:37:06 +0200

Isn't ARGV[0] supposed to hold the program name.

-W

On 24 May 2018 at 13:01, Jannick <address@hidden> wrote:
Hi,

After some net research it seems that gawk does not provide the name or path
of the awk program (called on the command line with -f flag) as a variable,
unless I am missing something obvious here.


If the above is true, may I suggest the following gawk enhancement:

1 - When calling gawk, define an environment variable, say AWKSCRIPT, as the
path to the (first) awk program (alternative: list of paths to the awk
programs as, e.g., delimited string) called on the command line, unless
AWKSCRIPT is already set. Inside the program use ENVIRON["AWKSCRIPT"].

2 - When terminating gawk, remove the variable AWKSCRIPT from the
environment if set in step 1.

Of course, I am aware that it is possible to use the -v flag to push the awk
program name as variable, but this is not as handy as the suggested
approach.

Please note that I am using gawk (version 4.2.1) on Windows 10 where a
shebang approach is not available out of the box.  I am saying that since it
might be that on unix shebang mechanism (wrapper?) makes the name of the
called awk script available from inside the awk program/script, but I am not
sure about that.

Many thanks,
J.




reply via email to

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