Welcome!

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

SignUp Now!

%$ Not retaining equal sign

May
401
4
Hello everyone,

Some time ago I wrote a small batch file that could be used to parse command line options and parameters. I use it daily and it works great.

I used the ":" to provide a value to a switch. For example:

GetOpt.btm /A:123

I would like to be able to use the '=' sign in addition to the ':' as most people are used to this. When I sent the following:

GetOpt.btm /A=123

the %$ variable seems to drop the equal sign and holds:

/A 123

How do I get the equal sign to be passed into my batch file so I end up with:

/A=123

Thanks for your thoughts and help. I'm not sure if this can be worked around, but I'm hopeful.

Michael
 
Escape it as ^=.

Also read about the INI directive "CMDBatchDelimiters" in the help's "Batch File Parameters".
 
Consider the difference between %$ and %*.
Code:
~\Work> type x.bat
@echo off
echo %%* %*
echo %%$ %$
quit

~\Work> x.bat foo /x=bar /y=3
%* foo /x=bar /y=3
%$ foo /x bar /y 3
 
Glad I was able to contribute something useful. Now I'm looking forward to your new version of GETOPT.BTM.
 
So equal signs are special and need to be escaped??? Oh no

i came here because i have a filename that is passing and failing depending on if or iff and it’s a filename with an equals in it. Have to do some testing now.
 
So equal signs are special and need to be escaped??? Oh no

Equal signs are not special, and do not need to be escaped. Except that a = is considered a whitespace character when the parser is assigning the %1 - %n batch variables (for compatibility with CMD). And IF has to do a lot of gymnastics because of people doing not-smart things like "if "a==b" (again, CMD compatibility).

Technically a = is not a valid filename character, but like % people will find a way to jam it into their filenames. Double or single quoting the argument will prevent TCC from considering it whitespace.
 
Today is the day that I’m very angry at bands who have song titles are mathematical equations.

Judging Type O Negative, NoMeansNo, and Man...Or Astro Man? hard today!! :D :D :D
 
You’re gonna hate me, but uhhhh....

I decided based on your feedback that I should prohibit equal signs in my music collection filenames.

I replaced the ascii equals signs (“=”) in my filenames with unicode equal signs (“=”, %@CHAR[65309])

Ummmmm..........There’s a directory coloring bug that happens when you do this.

1735671956214.webp


I think this is another situation where the internal displayable width() function might come up...
 
wcwidth! Like the python module! Ooooooooooooooooh i can’t wait! So awesome! thank you! This will make some amazing things possible that just weren’t before! :)
[i still haven’t officially cut over to 34 yet]
 
Back
Top