[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] Inconsistent External Command Spawning
From: |
David Millis |
Subject: |
[bug-gawk] Inconsistent External Command Spawning |
Date: |
Sat, 22 Jun 2013 13:49:41 -0700 (PDT) |
The ways gawk executes System() and piped commands is inconsistent again.
system() and pipe execution need to spawn the same way.
The subject of WHICH way has returned.
Previously discussed here.
http://lists.gnu.org/archive/html/bug-gawk/2012-04/msg00003.html
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
4.0.0: Pipe:Bat, System:Quotes
And, for completeness, GnuWin32's noncanonical build
3.1.6: Pipe:Quotes, System:Quotes
Quotes = cmd.exe /C blah
Requires a script author to concatenate fodder quotes around the external
command - because CMD predictably eats the first and last - but otherwise
executes exactly* as if the command were written in a shell prompt.
Bat = blah is written to a temporary batch file, then that is executed.
The external command will be subject to CMD's special batch parsing rules
regarding percents, among other things.
* In this post, I outlined in detail what I understood to be how the windows
runtime and cmd.exe interact to ultimately run the external command... the way
other languages do it.
http://lists.gnu.org/archive/html/bug-gawk/2012-04/msg00018.html
In the previous thread, Eli Zaretskii's responses started and concluded...
"The GnuWin32 way was simply unworkable, because
(a) there are differences in handling quoted arguments between the Windows
runtime libraries supplied with Windows Vista and later, and the runtime in
older Windows versions, like XP; and
(b) there are certain situations where you simply _cannot_ get the desired
effect by _any_ reasonable use of quotes, due to misfeatures of how quotes are
handled by the Windows APIs and the startup code of programs you invoke via the
'system' function."
"When I have time, or if I bump into that by chance, I will show you examples
of trouble with quoting+cmd+other apps."
I'm still not aware of any example showing the inadequacy of ALWAYS using this
in a script
system("\"+ any_command_line_regardless_of_quotes_or_wildcards +"\"")
on builds where
system(sysarg)
is
cmd.exe /C sysarg
The alleged inadequacy of fodder quotes was the whole argument for resorting to
temporary batch files.
Conversely,
system( gensub(/%/, "%%", any_command_line_regardless_of_quotes_or_wildcards) )
was deemed good enough for MOST cases when run as a batch.
So long as the spawn methods keep changing, it's difficult to write scripts
using external commands that reliably work across builds (a script that manages
this was attached in the link at the top).
David