Strange error message
Posted: 28 Mar 2014 02:32
I have the following bit of batch code in vv.bat:
If I run this with no argument, I get the following:
D:\>vv
D:\>set branch=
D:\>if // == // echo blah
blah
7/ was unexpected at this time.
D:\> if /i /~0,7/ == /Release/ (
D:\>
This makes no sense to me. %1 is blank, therefore so is branch, therefore it should go into the first if statement and echo "...branch not set" and fall out of the batch file. However even though branch is blank, it doesn't sat ...branch not set, but it seems to be doing something in the else part. It's not executing this else part, because the echo 0/1/2/3 are not shown, but it's complaining about the line with the ~ in it. What am I doing wrong?
Code: Select all
set branch=%1
if /%branch%/ == // echo blah
if /%branch%/ == // (
echo ...branch not set
goto :EOF
) else (
echo 0
if /i /%branch%/ == /Main/ (
echo 1
) else (
if /i /%branch:~0,7%/ == /Release/ (
echo 2
) else (
echo 3
)
)
)
If I run this with no argument, I get the following:
D:\>vv
D:\>set branch=
D:\>if // == // echo blah
blah
7/ was unexpected at this time.
D:\> if /i /~0,7/ == /Release/ (
D:\>
This makes no sense to me. %1 is blank, therefore so is branch, therefore it should go into the first if statement and echo "...branch not set" and fall out of the batch file. However even though branch is blank, it doesn't sat ...branch not set, but it seems to be doing something in the else part. It's not executing this else part, because the echo 0/1/2/3 are not shown, but it's complaining about the line with the ~ in it. What am I doing wrong?