bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Inconsistent External Command Spawning


From: Manuel Collado
Subject: Re: [bug-gawk] Inconsistent External Command Spawning
Date: Sun, 23 Jun 2013 17:02:43 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/17.0 Thunderbird/17.0

El 23/06/2013 6:32, David Millis escribió:
On Sat, 6/22/13, Eli Zaretskii <address@hidden> wrote:


Using Klabaster's binaries, which I think are built from canonical source.
4.1.0: Pipe:Quotes, System:Bat
4.0.1: Pipe:Bat, System:Bat

This cannot be true, because nothing's changed in Gawk on Windows
wrt pipes and system between 4.0.1 and 4.1.0.

Bizarre.
Canonical /pc/popen.c source indeed hasn't changed at all from 4.0.1 to 4.1.0. 
When __MINGW32__ is defined, both os_system() and os_popen() both call 
scriptify().

Hex editing Klabaster's 4.1.0 binary reveals the string "scriptify" in it, 
suggesting shared code, but behavior in that series HAS changed between versions...

- - -
BEGIN {
   # Batch will remove %1. Quote will print as is (no quote chars at risk of 
being eaten in this test).
   command = "ECHO x%1x";

   print "System";
   system(command);

   print "";

   print "Pipe";
   command | getline tmp;
   print tmp;
   close(command);
}
- - -
G:\>gawk410 -f exec_test.txt
System
xx

Pipe
x%1x

G:\>gawk401 -f exec_test.txt
System
xx

Pipe
xx
- - -
0.o

Sanity Check: Do your builds do this?

I've tested the system/pipe behavior with gawk 4.1.0 from ezwinports. There is something weird. system() commands are executed in cmd script mode, while pipe commands are executed as top-level console input (sorry for the text in spanish):

---- system-pipe.awk ----------
function testcommand( command,            tmp ) {
  print "Command <" command ">"
  print "System";
  system(command);
  close(command);
  print "Pipe";
  command | getline tmp;
  print tmp;
  close(command);
  print "";
}

BEGIN {
  testcommand( "ECHO x%1x" )
  testcommand( "ECHO x%TIME%x" )
  testcommand( "for %%K in (uno) do @echo x%%Kx" )
  testcommand( "for %K in (uno) do @echo x%Kx" )
}

------------------------------
I:\pruebas\awk\gawk4>gawk -f system-pipe.awk
Command <ECHO x%1x>
System
xx
Pipe
x%1x

Command <ECHO x%TIME%x>
System
x16:57:41,34x
Pipe
x16:57:41,37x

Command <for %%K in (uno) do @echo x%%Kx>
System
xunox
Pipe
No se esperaba %%K en este momento.


Command <for %K in (uno) do @echo x%Kx>
System
No se esperaba Kx en este momento.
Pipe
xunox
-------------------------------

With gawk 4.0.1 both system() and pipe commands are executed in cmd script mode.

-------------------------------
I:\pruebas\awk\gawk4>gawk401 -f system-pipe.awk
Command <ECHO x%1x>
System
xx
Pipe
xx

Command <ECHO x%TIME%x>
System
x16:59:55,12x
Pipe
x16:59:55,17x

Command <for %%K in (uno) do @echo x%%Kx>
System
xunox
Pipe
xunox

Command <for %K in (uno) do @echo x%Kx>
System
No se esperaba Kx en este momento.
Pipe
No se esperaba Kx en este momento.
--------------------------------

Regards,
--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado




reply via email to

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