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 11:41:36 -0400
User-agent: Mutt/1.5.23 (2014-03-12)

On Wed, May 13, 2015 at 12:42:25PM -0600, address@hidden wrote:
> Eli Zaretskii <address@hidden> wrote:
> 
> > How about adding a field to PROCINFO[] where we would save the full
> > original command line?
> 
> It's possible, but I don't know that it's worth the trouble of
> coding and documenting it.  It would need to be a subarray in PROCINFO.

It seems like a pretty straightforward patch (attached).  Maybe it's worth
adding.  I copied the subarray logic from symbol.c:load_symbols.  Did I get it
right?  There seem to be a lot of steps in creating a subarray.
Note: my first "unref(tmp)" call is not in load_symbols().  Is it correct,
or am I corrupting something?

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

Note: os_arg_fixup seems to threaten to mangle argv before it is saved
by save_argv.  It appears that os_arg_fixup is currently a no-op.  Might
that change?  If so, should we call save_argv before calling os_arg_fixup?

Regards,
Andy

Attachment: argv.patch
Description: Text document


reply via email to

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