- Thread Author
- #1
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.
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.
- Joined
- Jul 4, 2015
- Messages
- 8,970
String manipulate sucks in batch files. You'll probably want to remove the quotes before you compare
Dequote - remove quotes | Windows CMD | SS64.com
Powershell would be much easier to work with.
Dequote - remove quotes | Windows CMD | SS64.com
Powershell would be much easier to work with.
- Thread Author
- #3
- Joined
- Jul 4, 2015
- Messages
- 8,970
Similar threads
- Replies
- 0
- Views
- 56
- Replies
- 0
- Views
- 56
- Article
- Replies
- 0
- Views
- 40
- Replies
- 0
- Views
- 71
- Replies
- 0
- Views
- 1K