[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] enhancement: environment variable AWKSCRIPT?
From: |
arnold |
Subject: |
Re: [bug-gawk] enhancement: environment variable AWKSCRIPT? |
Date: |
Thu, 24 May 2018 05:45:37 -0600 |
User-agent: |
Heirloom mailx 12.4 7/29/08 |
Hi.
"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.
You can find the info using PROCINFO["argv"]:
| $ cat > /tmp/f1
| BEGIN { print "f1" }
| $ cat > /tmp/f2
| BEGIN { print "f2" }
| $ cat > /tmp/f3
| END {
| for (i = 0; i in PROCINFO["argv"]; i++)
| print i, PROCINFO["argv"][i]
| }
| $ gawk -f /tmp/f1 -f /tmp/f2 -f /tmp/f3 /dev/null
| f1
| f2
| 0 gawk
| 1 -f
| 2 /tmp/f1
| 3 -f
| 4 /tmp/f2
| 5 -f
| 6 /tmp/f3
| 7 /dev/null
Hope this helps,
Arnold