[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Is there a way to get the path to the current awk file?
From: |
arnold |
Subject: |
Re: [bug-gawk] Is there a way to get the path to the current awk file? |
Date: |
Thu, 17 Jan 2019 07:28:18 -0700 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
david kerns <address@hidden> wrote:
> On Thu, Jan 17, 2019 at 6:53 AM <address@hidden> wrote:
>
> > Peng Yu <address@hidden> wrote:
> >
> > > Hi,
> > >
> > > I don't see such a feature. Is there a way to get the path to the
> > > current awk file? Thanks.
> > >
> > > --
> > > Regards,
> > > Peng
> >
> > No, unfortunately, there is not.
> >
> >
> if you're running on Linux, you have a host of resources available in
> /proc/self/{cmdline,cwd,environ,fd/*} ... but it's not very portable
Yes, but the problem is even tougher, since awk allows multiple source
files (multiple -f options). Additionally, gawk provides file inclusion
and path searching for -f, -i, and @include. But in the end all these
files combine into a single program.
The information can be recovered manually, for command line files,
by looking at PROCINFO["argv"] and the various search path environment
variables, but that still doesn't cover @include files. (See the igawk
program for an example of how it might work.)
Arnold