[Mono-list] Command Line Parsing

Andrew Vick avick at remote-print.com
Tue Nov 8 12:40:58 EST 2005


Abe Gillespie wrote:
> Any thoughts on the bug (maybe?) I encountered.  I'll file it if
> someone confirms it.
> 
>>>2.  I think I ran into a bug playing around with the command line.
>>>When I send an asterisk "*" as one of the arguments I get some weird
>>>stuff.  On Windows it seems to work ok.  Try the fsollowing with an
>>>asterisk as one of the args:
>>>
>>>using System;
>>>class Program
>>>{
>>>   static void Main(string[] args)
>>>   {
>>>       foreach (string s in args)
>>>           Console.WriteLine(s);
>>>   }
>>>}

If you are seeing this bug under unix-like systems, be aware that command shells expand wildcards before passing the arguments to the application.  You can verify this by running the command:

echo *

That should give the same results as your program.  If you want to pass a literal *, you'll need to quote or escape it on the command line:

echo \*

-Andrew V.


More information about the Mono-list mailing list