WAD CMD incompatibility

May 20, 2008
473
2
TCC 28.01.14 x64 Windows 10 [Version 10.0.19042.1237]
TCC Build 14 Windows 10 Build 19042

In the Flutter language (Beautiful native apps in record time) install on Windows, there is a flutter.bat file that does not run in TCC, though it does run in CMD. The issue appears to be related to this syntax (from Command Redirection, Pipes - Windows CMD - SS64.com):
commandA || commandB Run commandA, if it fails then run commandB

The specific code in the batch file is 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

I do have git installed and can find it with the WHERE command (and WHICH). But, in TCC, the batch file just exits here. If I modify the file and put an ECHO after that line, it never reaches it. This makes me suspect the issue may be related to the double pipe on that line.

I do not see this syntax anywhere in the help. Is this supposed to be supported? Do I need to enable some specific option for it? I think I already have most of the CMD options enabled.

Thanks.
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
The || and && operators are in the Help under Conditional Commands.

If you separate two commands by && (AND), the second command will be executed only if the first command's exit code is 0.
If you separate two commands by || (OR), the second command will be executed only if the first command's exit code is non-zero.
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
The issue appears to be related to having both || and && on the same line.
Code:
$ where /q git || echo No go && echo uh oh
uh oh

$ where /q gitmo || echo No go && echo uh oh
No go
uh oh
 
May 20, 2008
11,411
99
Syracuse, NY, USA
Or put in some parentheses ...

where /q git || (ECHO Error: Unable to find git in your PATH. && EXIT /B 1)
 
May 20, 2008
473
2
Thanks for the reminders on 'help conditional'. WHERE does find git and return a non-zero.

Putting parens around the second pair of commands does work here, but exposes the next issue in a called batch file.
Code:
TCC: C:\flutter\bin\internal\shared.bat [35]  Unbalanced parentheses "& ( "

Line 35 is the second SET in this block:
Code:
WHERE /Q pwsh.exe && (
    SET powershell_executable=pwsh.exe
) || WHERE /Q PowerShell.exe && (
    SET powershell_executable=PowerShell.exe
) || (
    ECHO Error: PowerShell executable not found.                        1>&2
    ECHO        Either pwsh.exe or PowerShell.exe must be in your PATH. 1>&2
    EXIT 1
)
I guess I could add more pairs of parens around each pair of commands and nest the parens for doing that. But, as this batch file is provided as part of the Flutter install, I would prefer not to have to modify it and the other called batch files after each install/upgrade. I would need to weigh which nuisance is lesser, modification or just running CMD. Hopefully, enabling some other option will let it work without doing either.

It's a CMD bug; you can work around it in several ways or you can turn on the various CMD bug duplication options.
I have checked 'Duplicate CMD.EXE bugs' as well as 'CMD.EXE delayed expansion'. Are there other options I should enable?
 
May 20, 2008
473
2
Why not just run this bat file, or all your bat files, using CMD? Many of us do that. We run our btm files using TCC.
I very rarely start CMD and then only because something doesn't work as expected under TCC. I live in TCMD/TCC, regularly using aliases, functions, BTMs, etc. If I change that habit, it will likely be because I am running tmux/bash/zsh on Linux instead.
 
You can still live in TCmd/TCC, and still run a .bat file, that only works with cmd.exe
Code:
e:\utils>ver

TCC  28.01.14 x64   Windows 10 [Version 10.0.19043.1237]

e:\utils>cmd.exe /c ver

Microsoft Windows [Version 10.0.19043.1237]

e:\utils>

Just follow cmd.exe /c with the name of your .bat file.

After the .bat file has completed its run from cmd.exe, you are back in TCC.

Joe
 
I very rarely start CMD and then only because something doesn't work as expected under TCC. I live in TCMD/TCC, regularly using aliases, functions, BTMs, etc. If I change that habit, it will likely be because I am running tmux/bash/zsh on Linux instead.
That's the nice thing about TCmd/TCC, being able to run another shell to do something that cannot be done in TCC. Example;
Code:
e:\utils>ver

TCC  28.01.14 x64   Windows 10 [Version 10.0.19043.1237]

e:\utils>wsl bash --version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

e:\utils>wsl ls test*.bat
test.bat  test2.bat  testhta.bat  testkeys.bat

e:\utils>

I have an TCC alias;
Code:
usd=wsl qalc %1 USD to CAD
...that allows me to find out how much an amount of US Dollars is worth in Canadian Dollars;
Code:
e:\utils>usd 1
1 * dollar = approx. CAD 1.2361662

Thus, I can run my Linux programs from TCmd/TCC whenever I need to.

Joe
 
May 20, 2008
473
2
Joe,
I sometimes do the cmd /c ... in my TCC. It partly depends on whether it'll need elevated permissions or not; I don't often elevate TCC. I have wsl also, but had not tried running that within TCC, especially using the aliases. That's cool. Thanks for the ideas.
 
When I run ELEVATED.BAT from an un-elevated TCC in Windows 10 as follows;
Code:
start /pgm "cmd.exe" /b /c elevated.bat
...it returns not elevated.

When I run ELEVATED.BAT from an un-elevated TCC in Windows 10 as follows;
Code:
start /elevated /pgm "cmd.exe" /b /c elevated.bat
...it returns elevated.
Code:
::Elevated.bat
@setlocal
@echo off
NET FILE 1>NUL 2>NUL
if %errorlevel%==0 (echo Elevated) else (echo Not Elevated)
endlocal
pause

Thus, you can run your cmd.exe, and your .bat file, elevated from an un-elevated TCC.

Note that when I tried;
Code:
start /b /pgm "cmd.exe" /b /c elevated.bat
...no new console was created, and output from ELEVATED.BAT could be viewed.

When I tried;
Code:
start /b /elevated /pgm "cmd.exe" /b /c elevated.bat
...a new console was created, and destroyed, thus no output from ELEVATED.BAT could be viewed.

Not sure why that is.

Joe
 
Last edited:
When you install Take Command, it asks you whether you want to associate TCC with bat files. Just say no. If CMD is associated with bat files, then when you run a bat file, CMD will handle it. Maybe you also need to use an executable extension to get this to work from TCC's command line.
 
Last edited:
Similar threads
Thread starter Title Forum Replies Date
T CMD incompatibility Support 14
samintz A new CMD incompatibility Support 5
J Happy CMD/TCC incompatibility Support 0
sully9 How to? Unexpected %DATE% CMD variable format (vs DATE /T format) in CMDebug Support 1
L FTYPE in TCC, less quirky than in cmd.exe Support 3
Peter Murschall Single-line Do-CMD is a bit uncooperative. Support 6
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
T Date format date different from cmd Support 7
D Differences between TCC and CMD with COPY /b Support 4
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
E TCC/CMD difference Support 5
S How to? Deinstalling TC/reinstating execution of bat files by cmd in Win7 Support 31
D How to? Pass OpenHere Folder to CMD? Support 6
R Difference between TCC and CMD: variable names with hyphens Support 4
M WAD "Pictures" directory is empty in TCC but not in CMD or Explorer Support 4
rps Cmd history recall Support 4
rps Documentation TITLE cmd docs Support 0
Joe Caverly PUSHD with UNC path in CMD.EXE Support 2
W Starting program for word to pdf conversion (difference cmd and tcc) Support 13
Joe Caverly Using this CMD technique from TCC Support 17
W If command - different with CMD Support 6
I how to make TCC default/replace cmd.exe? Support 9
R FOR usage error from TCC but not from CMD Support 16
I findstr works in cmd but not in tcc Support 5
D Pasting Unicode data has different behavior on TCC and CMD Support 2
M Command line parsing differences between cmd.exe and TCC Support 6
Joe Caverly Works with CMD.EXE, no output with TCC.EXE Support 7
Joe Caverly tcommand(cmd) Support 13
L WAD ECHO. expansion of non-existent env-vars differs from CMD.exe Support 6
Joe Caverly "Functions" in cmd.exe batch files Support 6
Joe Caverly Works in debugger, not from cmd line Support 1
K CMD, TCC, VisualStudio 2017, VcVars* differences Support 1
D Does TCC improve CMD's implementation of ECHO? Support 6
P Labels in batch files: TCC vs CMD.exe Support 9
Patulus Yet another thread on CMD compatibility Support 16
A Fixed (CMD compat) START /D fails to recognize the switch option. Support 3
Joe Caverly CMD.EXE and filename(1).ext Support 3
H DOS CMD Sort+Add Sequence+Remove Sequence number Support 12
T WAD Difference between TCC and CMD in handling multi-command lines Support 6
C Nested IF syntax — TCC behaving differently to CMD Support 12
V Network share slowness vs CMD? Support 19
P Fixed Rexx .cmd files no longer work in TCC 20 Support 3
TT's Help! Uninstalling TCC did not restore cmd.exe as Win10 default batch file processor. Support 4
R How to? Display text same as in CMD Support 14
E How to? use Executable Extensions: .bat and .cmd Support 8
D Tab completion differences with cmd.exe Support 3
deleyd Fixed Behavior different than CMD Support 1
vefatica START, CMD vs. TCC Support 0
R Difference in behavior of RMDIR vs. CMD.EXE? Support 5
jogi Problem with FOR statement in TCC but not M$ CMD Support 1

Similar threads