Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

WAD nevermind! [lesson learned: no, you can’t set the command separator to %@CHAR[xxx]]

Jul
532
10
Discovered this one by accident!

Code:
setdos /x-3
setdos /c%@CHAR[1]
echo 100%%@CHAR[8221]

The smart quote is what breaks it. The char[8221]. It’s fine without it. It hangs indefinitely with it.

reproduceable on v33.00.20 with no ini file/fresh run

Please DON’T remove the ability to setdos /c to %@CHAR[1] though. That command is very picky about which characters you can use. None over ASCII[128]! I was dealing with a situation where i wanted to parse a file with possibly every character anyone would ever type, including command separator characters, and the safest way to do that was for me to set a command separator that would NEVER show up in any typed lyrics for any song ever made by any human in history. Was surprised when it accepted %@CHAR[1] (but not %@CHAR[7], hehe). What I really wanted was to set it to some weird unicode character that would truly never come up.

I forget why turning off the command separator altogether didn’t work for me. I think because I have a lot of %+ in my scripts? Whatever. I was surprised to find out you could echo 100%, but not with the smart quote at the end!

Hard for me to imagine how this would hang it.
 
Note that this also works with hardcoding the smart right quote. I just used %@CHAR as an example because i was scared the forum wouldn’t display it right. It hangs both ways for me.
 
Discovered this one by accident!

Code:
setdos /x-3
setdos /c%@CHAR[1]
echo 100%%@CHAR[8221]

You can see the current settings by typing setdos with no arguments. And if you try it, you'll find that what you are actually accomplishing with those first two lines is setting your command separator... to a percent sign. That can't possibly be good.

In fact you can set the command separator to almost any character in the BMP by just providing its value, either in decimal or in hex with a leading 0X. No need to muck about with SETDOS or @CHAR. So to use Control-A as your command separator:
Code:
setdos /c1

Or to use the double vertical bar:
Code:
setdos /c0x2016

Very simple, very easy, as Chef Tell used to say. And the same syntax also works with /E and /P.

(You can even use noncharacters like U+FFFF or U+FFFE. Anybody who uses those in filenames deserves whatever they get....)
 
::FACEPALM::

oh. my. god.

I should have realized that myself. Too much time in the weeds today.

Thank you!!
 
SET THE THREAD ON FIRE! DELETE DELETE DELETE hahahahah
 
The reason that you can't set /C to a character > 255 is because the command was written for 4DOS, and back then there weren't any characters > 255!

You can, to almost any character <= U+FFFF. I guess you haven't revisited that code for a few decades.

The real issue in her batch file is that the setdos /x-3 disables variable expansion, so the SETDOS /C picks up the percent sign instead of her intended character. And setting the command separator to the percent sign is... not a good thing.
 
You can, to almost any character <= U+FFFF. I guess you haven't revisited that code for a few decades.

You can't, unless you use the numeric value. The relevant code looks like this:

Code:
if ((iswalnum(*pszArg)) || (*pszArg > 255))
    return ERROR_EXIT;

The real issue in her batch file is that the setdos /x-3 disables variable expansion, so the SETDOS /C picks up the percent sign instead of her intended character. And setting the command separator to the percent sign is... not a good thing.

IMO setting it to anything (except &) is not a good thing.
 
IMO setting it to anything (except &) is not a good thing.

So, I was in a situation where i needed to turn off command separators without turning off piping.

It’s why i wish there was a setdos /x-5A , basically , a subsets of 5 that is just the command separator.

I’m parsing lyrics at the command line.
Downloaded lyrics are piped through a utility of mine that erases repeat lines and makes some minor cosmetic changes.
These then become the prompt parameter for WhisperAI’s AI-based audio transcription.

Which unfortunately means, i’m sending to the command line whatever it is people type.
(And possibly creating an unprecedented lyric-based attack vector, but that’s not my concern)
Hopefully no songs with "echo y | format c:\" in them, lolololol.

Anyway, any lyric file on planet earth could contain any character that might be SOMEone’s command separator.

The first time I hit a song with my separator in it, it was 30 minutes hunting down the bug.
Then I realized if I’d used the default separator of "&", I’d have found the bug sooner. Much much sooner. Many lyrics have ampersands in them.

So, I decided I should probably just set mine in the BAT file if I care so much, since setdos /x-5 wasn’t what I wanted to do.

And that’s exactly what I did.

But I wanted to set it to something that would NEVER come up in a lyric file. Ideally a letter from an alphabet of a language that I would never listen to the music of in a million years, or some non-displayable surrogate pair type character, or something. There’s enogugh

So, I thought setting it to %@CHAR[1] would be cute. Really i’d like to set it to some weird character like %@CHAR[43460] that I’ve never seen in my life (No really, try out echo Hi %@CHAR[43460] how are you and be amazed)
1736478389769.webp


That’s when I discovered >256 wasn’t valid. And i really wish it was for the aforementioned reasons.

So I started looking for weird characters. The winner was the Paragraph break symbol, but I decided to try control-characters. At that point, I was already in lala-land due to previous setdoses, and tricking myself into thinking I was setting a command separator of Ctrl-A, but really I was not.

Anyway though.. May I make a feature request?

The real answer is: i just need to make a bat file that handles the piping so that there is no pipe symbol in my %@EXECSTR, then setdos /x-5 would be viable option. Duh. That’s what I should have done all along.
 
Back
Top