How to? How can I say "if the command separator is not ~ then setdos /C~"

Jan 16, 2011
14
0
If someone using one of my scripts happens to have the command separator set to, say, ~ then when my script says
setdos /C~ the response is The parameter is incorrect. "/C" because the ~ already is the command separator.

Since the %+ pseudovariable is no longer supported, how can I say "if the command separator is not ~ then setdos /C~"
 
May 20, 2008
11,046
90
Syracuse, NY, USA
This is crude. I suspect there will be better ones.

Code:
if "%@execstr[echos * ~ echos *]" != "**" setdos /c~
 
May 20, 2008
11,046
90
Syracuse, NY, USA
"%+" may not be supported, or work in all situations, but it works in this situation (TCC 26.02.42). Of course, that may change without warning.

Code:
v:\> if "%+" != "~" echo ~ is not the command separator
~ is not the command separator
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,365
83
Albuquerque, NM
prospero.unm.edu
It doesn't get more elegant than that. Where did you find that one, Charles?
Wait, that isn't documented?

I guess I know about it because I was the one who originally requested it, umpteen years ago. It works with /E and /P too, and you can use hexadecimal if you prefer:
Code:
setdos /c0x7e