This seems really simple, but I am so stuck - been searching lots of nearly matching questions but just can't find the answer.
All I want to do is something like this:
echo c:\another\test\file.h(22,11) : warning 123: this is a test warning
But that gives the error: : was unexpected at this time.
So I tried:
echo "c:\another\test\file.h(22,11) : warning 123: this is a test warning"
Which produces: "c:\another\test\file.h(22,11) : warning 123: this is a test warning". But I don't want the quotes. So I tried using the escape character "^":
echo c^:\another\test\file.h(22,11) ^: warning 123^: this is a test warning
But this had no effect. How can I achieve this?
UPDATE:
This line of code is within an if block, which appears to make a difference!:
if exist "somefile" (
echo c:\another\test\file.h(22,11) : warning 123: this is a test warning
)
I believe your command line is placed within a paranthesised block of code, like this, for example:
if exist "c:\another\test\file.h" (
echo c:\another\test\file.h(22,11) : warning 123: this is a test warning
)
So the closing ) in the echo command line is interpreted as the closing one of the entire block, leaving the portion : warning 123: this is a test warning as an invalid command line.
To solve it, you need to escape the ) by preceding a caret ^, which is cmd's escape character:
if exist "c:\another\test\file.h" (
echo c:\another\test\file.h(22,11^) : warning 123: this is a test warning
)
Therefore the colon : in front of warning: ... is actually not causing the problem here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With