bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Gawk 4.0.0 Exec's Weirdly


From: Eli Zaretskii
Subject: Re: [bug-gawk] Gawk 4.0.0 Exec's Weirdly
Date: Fri, 30 Sep 2011 17:55:01 +0300

> Date: Tue, 20 Sep 2011 11:09:58 -0700 (PDT)
> From: David Millis <address@hidden>
> 
> # At least up to 3.1.6:
> # - Loop (unquoted): error
> # - System (unquoted): error
> # - Loop (quoted): works
> # - System (quoted): works
> 
> # 4.0.0:
> # - Loop (unquoted): works
> # - System (unquoted): error
> # - Loop (quoted): error
> # - System (quoted): works
> # Presumably added its own wrapping
> # to fix the unquoted loop. Which makes
> # it different from System(), and from
> # every other language's exec funcs.

Nothing's changed in Gawk in the code that is involved in running
external commands, either via the `system' function or by piping their
output to `getline'.  In fact, Gawk 3.1.6 that I compiled myself
exhibits the same inconsistent behavior that you see in 4.0.0.  And I
see the same behavior in 3.1.5.

The issue here is not the code in Gawk, but how it was built by
whoever produced the binaries you are using.  My binaries are built by
myself from sources using the stock Makefile provided for MinGW
builds.  I'm guessing that your 3.1.6 came from GnuWin32, where the
person who built them did something to change the way Gawk is built.

Specifically, the issue is with the popen.c module, which by default
is compiled into the Windows binary.  This module wraps the Windows
`popen' function with code which writes the command to a temporary
batch file and then invokes cmd.exe to run that batch file.  Since the
command is written to a batch file, it no longer needs the extra
quotes, and if you add them, it fails.

The wrapper code is supposed to cause Gawk heed to the SHELL
environment variable.  I'm inclined to change the wrapper so that if
SHELL is not defined in the environment, it does nothing and calls the
original `popen' from the C library with the original command.  If no
one objects, I will do it when I have time.



reply via email to

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