[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Percent Signs in External Commands on Windows
From: |
David Millis |
Subject: |
Re: [bug-gawk] Percent Signs in External Commands on Windows |
Date: |
Mon, 9 Apr 2012 15:24:12 -0700 (PDT) |
--- On Mon, 4/9/12, Eli Zaretskii <address@hidden> wrote:
> (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;
Do you know a url where I can read up on that?
> (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.
I don't understand how this is different from (a). CMD /C WHATEVER would strip
the chaff quotes before the external programs could see them (if users add such
quotes). There's no burden of escaping inner chars.
> I'd say, doubling every % will solve 99% of problems. The only problem
> that will be left is the use of %FOO% where FOO is an existing
> environment variable. Am I right?
... where FOO doesn't begin with a percent, digit, asterisk, tilde (with
optional chars), and FOO doesn't follow another variable name (the leading
percent would belong to it instead of FOO).
Doubling percents everywhere would catch %1's and %word%'s, which is what I
stumbled on while gawk was passing urlencoded strings to wget (%20 for spaces,
etc). I figured other people might more often deliberately use percents for env
vars though. I've never noticed precedent to double percents as a workaround in
a language, and since the temp batch mechanism is undocumented, it seemed worth
reporting in case it was deemed too unintuitive.
Granted, rewriting any original command string with presubstituted values would
be cleaner. In my code, I do that anyway...
#command = "echo %TEMP%";
command = "echo " ENVIRON["TEMP"];
if (_execSystemAsCmdBatch == 1) gsub(/%/, "%%", command);
system(command);
> the Windows port of GNU Make disregards this issue altogether
I'm not familiar with make, but doesn't it have the long-standing convention of
using $(FOO) for everything, including env vars? And I have difficulty
imagining a scenario where an unintended percent would sneak into a filename or
compiler/archiver args, so it's not surprising make's doing okay.
Sorry for the drawn-out topic. Gawk's my favorite scripting language
(cross-platform, standalone exe, regex, and no compiling). With each new
version, I do a little chair dance. :P
Btw, is it tricky to compile/cross-compile it for mingw? I'm inexperienced with
tracking down dependencies for gcc and Dev-Cpp/wxDev-Cpp/CodeBlocks, finding
the right DEFINEs, etc.
David Millis
- [bug-gawk] Percent Signs in External Commands on Windows, David Millis, 2012/04/09
- Re: [bug-gawk] Percent Signs in External Commands on Windows, Eli Zaretskii, 2012/04/09
- Re: [bug-gawk] Percent Signs in External Commands on Windows,
David Millis <=
- Re: [bug-gawk] Percent Signs in External Commands on Windows, Eli Zaretskii, 2012/04/10
- Re: [bug-gawk] Percent Signs in External Commands on Windows, David Millis, 2012/04/11
- Re: [bug-gawk] Percent Signs in External Commands on Windows, Eli Zaretskii, 2012/04/11
- Re: [bug-gawk] Percent Signs in External Commands on Windows, David Millis, 2012/04/11
- Re: [bug-gawk] Percent Signs in External Commands on Windows, Eli Zaretskii, 2012/04/12
- Re: [bug-gawk] Percent Signs in External Commands on Windows, David Millis, 2012/04/12
- Re: [bug-gawk] Percent Signs in External Commands on Windows, David Millis, 2012/04/13
- Re: [bug-gawk] Percent Signs in External Commands on Windows, David Millis, 2012/04/13
- Re: [bug-gawk] Percent Signs in External Commands on Windows, David Millis, 2012/04/13
- Re: [bug-gawk] Percent Signs in External Commands on Windows, David Millis, 2012/04/19