[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: Nelson H. F. Beebe
Subject: Re: [bug-gawk] Percent Signs in External Commands on Windows
Date: Wed, 11 Apr 2012 08:27:21 -0600 (MDT)

With all this discussion of the brain-damage of Microsoft Windows
shells in their processing of command-line arguments, no one seems to
have mentioned the possibility of representing special characters as
octal or hexadecimal escape sequences to hide them from special
interpretations as quoting characters, escape characters, or
pattern-matching characters.

So, the questions for the users of gawk on Windows are:

        Does a command invoked from gawk via system() or a pipeline

                programname \042 \047 \052

        pass the literal characters quotation-mark, apostrophe, and
        asterisk to the program, or does the program see character
        strings of four characters each, as shown?

        And does \052 get converted to * which gets expanded into
        a list of matching files, or does it do the job of hiding
        a literal asterisk?

        And do those backslashes need to be doubled, as in

                programname \\042 \\047 \\052

        or are they just treated as ordinary characters?

Some further background for non-Windows users: unlike the case in Unix
where the shells have ALWAYS handled command-line argument quoting and
pattern matching, in PC-DOS, arguments are passed directly to the
program, which must then take on a job that the DOS shell should have
done once and for all.  Then Windows came along, first running on top
of the DOS shell, and then later, on bare hardware with the shell
supplied on top of Windows as CMD.EXE.  Because the command-line was
never popular among most Windows users, it did not get much attention,
and its painful deficiencies never got properly fixed.

In 2006, Microsoft introduced the PowerShell, which is an optional
(but free) download, that provides a powerful shell with many
interesting features, but alas, one that is not even close to a POSIX
shell.  Because PowerShell is optional, gawk programmers might not
want to rely on its being available, but it should be investigated
whether it solves the horrid problems of CMD.EXE: it it does, perhaps
we should just declare that gawk users on Windows are strongly
recommended to install PowerShell.  For details, see for example


- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- University of Utah                    FAX: +1 801 581 4148                  -
- Department of Mathematics, 110 LCB    Internet e-mail: address@hidden  -
- 155 S 1400 E RM 233                       address@hidden  address@hidden -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe/ -

reply via email to

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