TCC/CMD difference

Jun 2, 2008
40
0
Denmark
Hi

I have discovered this difference while running the flutter.bat file provided by Google:
Code:
REM Test if Git is available on the Host
where /q git || ECHO Error: Unable to find git in your PATH. && EXIT /B 1

In CMD, if the first command succeeds, nothing happens. If it fails, a message is shown and the script is terminated. In TCC, if the first command succeeds, no message is shown but the script is still terminated. So it seems that CMD and TCC do not quite agree on operator precedence here.

A well-placed set of parentheses solves this:
Code:
REM Test if Git is available on the Host
where /q git || (ECHO Error: Unable to find git in your PATH. && EXIT /B 1)
but this correction will have to be made every time Google updates this file.

- Ebbe
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,568
97
Albuquerque, NM
prospero.unm.edu
You might try the Duplicate Bugs option:

Duplicate-bugs.png
 
Jun 2, 2008
40
0
Denmark
Bump!

I ran into this bug again yesterday. And since all interaction with flutter goes through the flutter.bat file, this is really annoying.
 

rconn

Administrator
Staff member
May 14, 2008
12,425
153
I have discovered this difference while running the flutter.bat file provided by Google:
Code:
REM Test if Git is available on the Host
where /q git || ECHO Error: Unable to find git in your PATH. && EXIT /B 1

That line isn't correct in either CMD or TCC. The && should be a single & - an ECHO will always return a 0, so the && is pointless. The only reason to use && is if you wanted to do a conditional operation here -- which you don't.

In CMD, there's a bug where it throws away the entire command line following a failed ||. I chose not to emulate this bug because (1) it's dumb, and (2) it would break existing TCC functionality.
 
Oct 29, 2008
91
0
You should submit a pull request to change it to:
Code:
where /q git || (ECHO Error: Unable to find git in your PATH. & EXIT /B 1)
which is correct for CMD.‍EXE as well as TCC.‍EXE. the fact that paren-less it does different things with & vs && means that it works at all is a bug.
 

Similar threads