-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Win32 command line parsing explained #326
Comments
From [email protected]Created by [email protected]The README.win32 file in the perl distribution seems to indicate The Win32 command shells *do not* parse the command line into This string is returned from the GetCommandLine(void) system call. Thus the notion of UNIX-like argc/argv passed to main() is an Also note, that most C compilers do come with source code for their The two exceptions are: Neither of these two exceptions apply to the CreateProcess system Hope this helps you make an even better Win32 port of perl. Perl Info
|
From @vanstynWhile trying to clear out some ancient cruft from the bug database, I have no idea whether his assertions about win32 command-line parsing Hugo |
From [Unknown Contact. See original ticket]
They look mostly correct to me, but I've never tried to figure out |
From @gsarOn Thu, 13 Jul 2000 17:13:39 BST, Hugo wrote:
They're correct, but he's talking about it from the POV of the low-level
I don't see anything that needs changing there. However, we do need to fix various amounts of brokenness that prevent Sarathy |
From @vanstynIn <200007131720.KAA12643@molotok.activestate.com>, Gurusamy Sarathy writes: Ok, I'll mark the bugid closed. Hugo |
From [Unknown Contact. See original ticket]From: Gurusamy Sarathy [mailto:gsar@ActiveState.com]
I could argue that the user needs to know that there are two forces at work A particular gotcha with the 4NT shell is that if you fail to double % I don't think it's README.win32's place to document the idiosyncracies of Does the attached patch explain things any better? [BTW, note that I changed the comment about quoting redirection characters - Paul. ---- Patch for perlwin32.pod ---- Inline Patch--- perlwin32.pod.orig Thu Jun 29 10:48:02 2000
+++ perlwin32.pod Fri Jul 14 10:43:30 2000
@@ -283,29 +283,38 @@
shells found in UNIX environments, you will be less than pleased
with what Windows offers by way of a command shell.
-The crucial thing to understand about the "cmd" shell (which is
-the default on Windows NT) is that it does not do any wildcard
-expansions of command-line arguments (so wildcards need not be
-quoted). It also provides only rudimentary quoting. The only
-(useful) quote character is the double quote ("). It can be used to
-protect spaces in arguments and other special characters. The
-Windows NT documentation has almost no description of how the
-quoting rules are implemented, but here are some general observations
-based on experiments: The shell breaks arguments at spaces and
-passes them to programs in argc/argv. Doublequotes can be used
-to prevent arguments with spaces in them from being split up.
-You can put a double quote in an argument by escaping it with
-a backslash and enclosing the whole argument within double quotes.
-The backslash and the pair of double quotes surrounding the
-argument will be stripped by the shell.
-
-The file redirection characters "<", ">", and "|" cannot be quoted
-by double quotes (there are probably more such). Single quotes
-will protect those three file redirection characters, but the
-single quotes don't get stripped by the shell (just to make this
-type of quoting completely useless). The caret "^" has also
-been observed to behave as a quoting character (and doesn't get
-stripped by the shell also).
+The crucial thing to understand about the Windows environment is that
+the command line you type in is processed twice before Perl sees it.
+First, your command shell (usually CMD.EXE on Windows NT, and
+COMMAND.COM on Windows 9x) preprocesses the command line, to handle
+redirection, environment variable expansion, and location of the
+executable to run. Then, the perl executable splits the remaining
+command line into individual arguments, using the C runtime library
+upon which Perl was built.
+
+It is particularly important to note that neither the shell nor the C
+runtime do any wildcard expansions of command-line arguments (so
+wildcards need not be quoted). Also, the quoting behaviours of the
+shell and the C runtime are rudimentary at best (and may, if you are
+using a non-standard shell, be inconsistent). The only (useful) quote
+character is the double quote ("). It can be used to protect spaces in
+arguments and other special characters. The Windows NT documentation
+has almost no description of how the quoting rules are implemented, but
+here are some general observations based on experiments: The C runtime
+breaks arguments at spaces and passes them to programs in argc/argv.
+Doublequotes can be used to prevent arguments with spaces in them from
+being split up. You can put a double quote in an argument by escaping
+it with a backslash and enclosing the whole argument within double
+quotes. The backslash and the pair of double quotes surrounding the
+argument will be stripped by the C runtime.
+
+The file redirection characters "<", ">", and "|" can be quoted by
+double quotes (although there are suggestions that this may not always
+be true). Single quotes are not treated as quotes by the shell or the C
+runtime. The caret "^" has also been observed to behave as a quoting
+character, but this appears to be a shell feature, and the caret is not
+stripped from the command line, so Perl still sees it (and the C runtime
+phase does not treat the caret as a quote character).
Here are some examples of usage of the "cmd" shell:
@@ -344,6 +353,13 @@
Discovering the usefulness of the "command.com" shell on Windows 9x
is left as an exercise to the reader :)
+
+One particularly pernicious problem with the 4NT command shell for
+Windows NT is that it (nearly) always treats a % character as indicating
+that environment variable expansion is needed. Under this shell, it is
+therefore important to always double any % characters which you want
+Perl to see (for example, for hash variables), even when they are
+quoted.
=item Building Extensions
|
From @jhi
Applied, thanks. |
Migrated from rt.perl.org#1151 (status was 'resolved')
Searchable as RT1151$
The text was updated successfully, but these errors were encountered: