Windows 7 Windows batch file syntax problem

eldiener

Honorable Member
In a batch file I have a line such as:

if "%1" == "some_value" goto somegoto

in order to test a parameter against a value. If however I need to pass as the first parameter to my batch file a string with some equal signs in it such as:

"cxxflags=-std=c++11"

I pass it with quotes so it is a single parameter, else batch file processing will split it on the various equal signs in the parameter. However when it processes this single batch parameter in my statement above I get the message:

=-std=c++11"" was unexpected at this time on the line in the batch file of:

if ""cxxflags=-std=c++11"" == "some_value" goto somegoto

How can I get the batch file to make the comparison correctly ? It obviously doesn't like the form of comparison of:

if "%1" == "some_string"

when %1 is itself a quoted string with an equal sign in it.
 
Thanks !

Powershell docs have always seemed very poor to me. If I really want something better I use Python. Using the
%~1 syntax solved my problem in the batch file.
 
Back
Top