On 01.02.2022 14:15, Kenny McCormack wrote:
"man gawk" (for Gawk 5.0) says:
PROCINFO["command", "pty"]
Use a pseudo-tty for two-way communication with
command instead of setting up two one-way pipes.
Prior to that, it says "These variables may be set to control ...", but doesn't really say what to set them to. Normally, this sort of phrasing implies that setting them to anything - i.e., just causing them to exist - will qualify as "being set".
Just a nitpick...
PROCINFO["command", "pty"] makes it already "exist", just its value
is unset; the predicate (cmd,"pty") in PROCINFO evaluates to true.
Assigning an undefined variable x as in PROCINFO["command", "pty"] = x
will also make it exist, but will still have its value status 'unset'.
If variable x has a defined value then its value is set, but the outcome depends; as you say, values of 0 or "" will not activate the feature.
We have a couple possible states; existing, unset, set, non-null set.
The 'set' state is indeed irrelevant, and using that word misleading,
I agree.
Janis
However, experimentation shows that here, the variable needs to be set to a non-zero value in order to take effect. If is set to 0 or "", it will not use a pty.
Use the following program to test:
$ gawk 'BEGIN { cmd="tty";PROCINFO[cmd,"pty"];cmd |& getline;print }'
not a tty
$ gawk 'BEGIN { cmd="tty";PROCINFO[cmd,"pty"]=0;cmd |& getline;print }'
not a tty
$ gawk 'BEGIN { cmd="tty";PROCINFO[cmd,"pty"]=1;cmd |& getline;print }' /dev/pts/N
This should either be fixed in the documentation or fixed in the code
(i.e., the code changed so that merely setting it is enough).
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)