DO /L, where did my string go?

#4
Actually, /Q seems to turn off looking for more switches. It works fine without quotes.
Code:
v:\> do x in /q /c /p /l /o:s (echo %x )
/c
/p
/l
/o:s
Couldn't /L behave similarly?

Oops! But with /Q, it does find (and get rid of) another /Q!
Code:
v:\> do x in /q /q /c /p (echo %x )
/c
/p
 

rconn

Administrator
Staff member
May 14, 2008
10,646
97
#5
No, /L can't behave like /Q without breaking backwards compatibility.

/Q will only work without quotes if you have no whitespace in your arguments.

Your examples cannot work unless DO has a custom parser. There's no way for a general-purpose parser to know that sometimes your options are options, and sometimes your options are arguments, and only you know the difference.

And DO is not going to have a custom parser.
 
#6
Never mind. It just doesn't make sense to me. After /L, it accepts /q, /c, and /p as strings. But it won't accept /L (though it already has one) or /o:x (which, as a switch, is meaningless with /L).
Code:
v:\>  do x in /l /q /c /p (echo %x )
/q
/c
/p

v:\> do x in /l /o:x /q /c /p (echo %x )
/q
/c
/p

v:\> do x in /l /l /o:x /q /c /p (echo %x )
/q
/c
/p
 

rconn

Administrator
Staff member
May 14, 2008
10,646
97
#7
Nothing unexpected there -- some options (like /C, /P, and /Q) are only valid if they're at the beginning of the command.

Your /L /L is interpreted as a single option that you inexplicably repeated. It's not the parser's job to make assumptions about what you might have intended, and in fact this is a fairly common occurrence with aliases.

And the /O:x is processed and removed before the /L is processed.