Mail Archives: cygwin/1996/10/30/03:55:01
> Date: Mon, 28 Oct 1996 20:17:44 -0500
> From: DJ Delorie <dj AT delorie DOT com>
>
> > gawk isn't broken. bash isn't broken. If anything is "broken," it's
> > COMMAND.COM (CMD.EXE) [DOS shell] -- actually it's just different. gawk
> > does not interpret the single quotes; that's the shell's job. DOS shell
> > does not understand single quotes so it passes them to the gawk as is.
>
> COMMAND.COM does absolutely no interpretation of the command line at
> all. It send it to you as-is, including the space after the command
> name and the carriage return at the end. It does not know about
> quotes, single or double. Parsing it is entirely up to the
> application.
Well, yes and no. It is entirely up to the application yes. But most
programmers use the built in parsing provided by their compiler when they
write their 'main' function. After all, somebody splits the arguements up
into that argv array and passes it to main.
In Cygwin ports of gawk, or anything else for that matter, the work gets
done by the cygwin.dll. The dll tries to figure out whether you are running
from bash or not and then processes the command line appropriately. In fact
it does some very heavy processing, expanding wildcarded arguments and, most
likely, quotes and things. More or less it tries to duplicate what bash
does for the application, then it does the more traditional job of splitting
the command line into tokens for main.
> Perhaps what cygnus's gawk is getting is a single argument (argv[1])
> that includes the entire command line, including all the stray quotes,
> as if you had typed this at the unix command line:
>
> gawk \''{ printf("%d %s\n", $3, $2"); }'\'
I doubt this. I don't think that most of the UNIX tools ported with Cygwin
would understand a single argv[1] with everything from the command line,
and there are many UNIX tools ported with Cygwin which work fine from the
command line. If, on the other hand, you mean that the single quotes might
be included in the argument that is supposed to be quoted here, which is
a mistake in the startup code's tokenization, I agree, that is a distinct
possibility.
It's pretty simple to test. Write a program like this:
main (int argc, char* argv[])
{
int x;
for (x = 1; x < argc; x++)
{
printf ("Arg %d: \"%s\"\n", x, argv[x]);
}
}
And run it with the command line
test '{ printf("%d %s\n", $3, $2"); }'
And you will see exactly what the cygwin dll has done with that command line.
You might try running it under bash and the ordinary command line, if they're
different then there is a problem that needs fixin'.
If you have the library source from Cygnus you can try digging through it
to find where the command line gets parsed if you are not started from
bash. I think that's where you'll find your problem.
Colin.
P.S. Just out of interest, every compiler startup code I have ever used under
Win32 or DOS understands double quotes and tokenizes the command line.
Single quotes is another thing entirely.
------------------------------------------------------------------------------
Colin Peters ------------ Saga Univ. Dept. of Information Science, Saga, JAPAN
http://www.fu.is.saga-u.ac.jp/~colin/home.html - colin AT bird DOT fu DOT is DOT saga-u DOT ac DOT jp
$@%3%j%s(J $@%T!<%?!<%:(J - $@:42lBg3XM}9)3XIt>pJs2J3X2J>pJs4pAC3X9V:B(J
- Current favorite kanji: $@@2$l(J $@<G AT 8(J -
-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -