[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: |
Eli Zaretskii |
Subject: |
Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time? |
Date: |
Fri, 15 May 2015 10:40:38 +0300 |
> From: Aharon Robbins <address@hidden>
> Date: Fri, 15 May 2015 06:12:34 +0300
> Cc: address@hidden, address@hidden
>
> > I could see some use to having at least the program name under which
> > it has been called available somewhere. The behavior of the program
> > could then be changed when called under a different name
> > (symlinking).
>
> GNU standards disallow basing behavior on the program's name.
Only for GNU software. Users can legitimately use GNU tools to write
software that doesn't conform to GNU standards.
> But
> the real issue is #!. On different systems, if you have foo.awk with
>
> #! /usr/bin/gawk -f
>
> then the C level argv[0] might be any of "foo.awk", "gawk", "/usr/bin/gawk",
> or who knows what. This is documented in the manual; you just can't
> rely on the value of ARGV[0] to be anything useful. Sad, but true.
The semantics of argv[0] is not portable, that's true, and not only
because of the shebang: it also depends on whether Gawk was invoked by
a relative file name or found through PATH search, for example.
But that doesn't mean that having a way of getting at argv[0] as it is
known to Gawk is useless. On any reasonable OS, you can trick the
system into producing a full absolute file name in argv[0], in most
cases, so having access to that from the script is a useful feature,
IMO. At least it is not less useful than some of the other PROCINFO
entries, like "egid" and "ppid", for example (which are also
non-portable).
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?, (continued)
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?, Eli Zaretskii, 2015/05/14
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?, Andrew J. Schorr, 2015/05/14
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?, Aharon Robbins, 2015/05/14
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?, Andrew J. Schorr, 2015/05/14
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?, Aharon Robbins, 2015/05/15
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?, Eli Zaretskii, 2015/05/15
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?, Andrew J. Schorr, 2015/05/15
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?, Joep van Delft, 2015/05/14
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?, Eli Zaretskii, 2015/05/14
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?, Aharon Robbins, 2015/05/14
- Re: [bug-gawk] Can a GAWK script access its full path\name at "run-time?,
Eli Zaretskii <=