On 05/26/2012 12:05 PM, Ciaran wrote:
>
>
> On Saturday, May 26, 2012, Pat Thoyts wrote:
>
> On 25 May 2012 23:05, Timothy Madden <
termin...@gmail.com
I saw the instaweb part, great job !
But I am new to all this and I do not know how instaweb is related to
FastCGI or mod_perl, which is what I am trying to achieve. I see you are
happy to run instaweb with plain old CGI.
I tried to start a patch to get gitweb running with ActivePerl, and I
quickly ran into the problem of guessing the appropriate quoting for the
Windows command shell cmd.exe. This is what I found until now:
1. The appropriate quoting is not exactly documented. I do not have an
official source for this statement, but unofficial ones say so and I
actually could not find such documentation. If you know of such
documentation please let me know. Until then, I had to read Microsoft VC
run-time library source code to figure things out.
2. Under Windows each application is responsible for splitting the
command line into words and populating argv, from a single plain text
string holding the command line as entered by the user, including any
existing quoting. This may not be obvious to the programmer since it is
done by the C run-time library before main() is entered, but that is the
rule on Windows.
3. The command shell (cmd.exe) still has to scan the command line though
to expand environment variable names, to find I/O redirections with >
and <, to find multiple-statement operators like |, ||, & and &&, and to
find statement groups with ( and ).
4. Since there are now two applications parsing the command line, it is
very well possible for the two to parse it differently and get different
meanings for it ! Fortunately the first of the two apps, the command
shell, does not really care about the meaning of the command line arguments.
5. The application usually parses the command with the MS VC++ runtime
library (msvcrt##.dll), which uses the following rules:
1. arguments are sparated by space or tab characters, unless they
are quoted
2. at any point in the command line you can start quoting with a
double-quote character, and end quoting with a matching
double-quote character.
3. If you want a literal double-quote, precede it with a blackslash.
4. if you don't want a literal double-quote, but you want a literal
backslash before the quote, use a double backslash. If you want
a double backslash before the quote, make sure to double them
both ...
5. if you want a literal backslash and a literal double quote,
prefix each of them with a backslash. Again, if you want more
backslashes instead of one, than double each of them.
6. The same rules for a literal quote apply inside quoted arguments,
but there a quote can also be represented as a pair of quote
characters.
6. The command shell has different rules: it will look the the shell
special characters (|, &, <, >) anywhere in the line that is past an
even number of quotes (including 0 such quotes), and it will ignore
special characters anywhere that is past an odd number of quotes on the
command line. Any backslashes are ignored.
However I see that not all applications follow the msvcrt rules. For
example MinGW g++ and Windows ftp will see
" word word2""" word3"
as a single argument, while msvcrt says there are two arguments there,
and I am not sure why this is happening. Cygiwn rm, Win32 python27 and a
windows batch file (.cmd) will see the correct number of words there.
However Windows .cmd files, including git on Windows, do not see any
backslashes as escapes for double-quotes on the command line.
It is all such a mess. Do you have more information about this ?
I need to properly quote Windows command lines, in order to convert
"List form of pipe open" to "string form" in gitweb.cgi.
Thank you,
Timothy Madden