Just because

.
Actually, it's probably the space (or lack thereof) having more of an
effect. PowerShell treats spaces as delimiters; it's not so much a "-" that
it looks for to begin an argument name, but rather " -" (that is, a space
and a dash). It looks for the next space to seperate the argument name and
value. The colon is obviously another character it "looks" for - I don't
think it wants to see them in argument names, and in your last example it
would "think" that the colon was part of the argument name (no spaces) so
"broke" it there.
--
Don Jones
Windows PowerShell MVP
Founder:
www.ScriptingAnswers.com
Co-Author: "Windows PowerShell: TFM"
"Dan" <dz.open@gmail.com> wrote in message
news:1178921284.945251.87840@u30g2000hsc.googlegroups.com...
>I discovered that when I execute a program from the PS command line
> and I try to pass an argument that starts with a hyphen (-) and
> contains a colon (
, the argument will be split into 2 arguments at
> the colon.
>
> To demonstrate, I wrote a simple python script then merely echoes out
> all the arguments in argv:
>
> PS C:\3rdParty> .\testPSArgs.py c:\goodbye
> arg: C:\3rdParty\testPSArgs.py
> arg: c:\goodbye
> PS C:\3rdParty> .\testPSArgs.py =c:\goodbye
> arg: C:\3rdParty\testPSArgs.py
> arg: =c:\goodbye
> PS C:\3rdParty> .\testPSArgs.py hello=c:\goodbye
> arg: C:\3rdParty\testPSArgs.py
> arg: hello=c:\goodbye
> PS C:\3rdParty> .\testPSArgs.py -hello=c:\goodbye
> arg: C:\3rdParty\testPSArgs.py
> arg: -hello=c:
> arg: \goodbye
>
> Now, of course, the workaround is fairly simple, merely enclose the
> argument in quotes:
> PS C:\3rdParty> .\testPSArgs.py "-hello=c:\goodbye"
> arg: C:\3rdParty\testPSArgs.py
> arg: -hello=c:\goodbye
>
> I was just wondering, why does it parse the command line in this way?
>
> thanks,
> Dan
>