Yet another optparse

Rueschi rueschi at GIquadrat.de
Wed Jan 10 04:33:17 PST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kirk McDonald schrieb:
> Rueschi wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Kirk McDonald schrieb:
>>> CyaNox wrote:
>>>> Does your implementation account for the following:
>>>>
>>>> app --file="foo bar"
>>>> app --file "some --file with spaces and quoted"
>>>>
>>> Quoting is taken care of by the shell before the argument even gets to
>>> your program.
>>
>> This is not true on Windows systems, where the whole command line is
>> passed in only one string. The parsing is left to the program.
> 
> Not so. The examples I used in my previous post all worked equally well
> for me on Windows XP and Linux, and I have been testing optparse on both.

So your parser uses the argument array from the main() function which is
called by the extern(C) main() from phobos/internal/dmain2.d which is called
from the underlying C runtime which calls the Win32 GetCommandLine() API
function that returns the whole command line in one string.

You should pray that the different C runtime implementations parse the
command line string the same way as the linux shell does. If not, you
could get different results for exotic arguments :)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32)

iD8DBQFFpN0NxpVjSwvEWI4RAlmJAKD5Gejwt8YViRM2qvt/r3so2kGZAQCgihMB
esvwmPmPLEps7jNqx8oHCrk=
=jlF0
-----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list