break script on syntex error

Apr 1, 2010
43
0
in CMD, syntex error of internal command will break the script.
for example:
Code:
@echo off
for /q %%i in (.) do echo %%i
echo done
/q is invalid FOR switch in both CMD and TCC.
CMD will print "/q was unexpected at this time." and back to prompt.

but TCC will execute "echo done".
 
May 20, 2008
3,515
4
Elkridge, MD, USA
| in CMD, syntex error of internal command will break the script.
| for example:
|
| Code:
| ---------
| @echo off
| for /q %%i in (.) do echo %%i
| echo done
| ---------
| /q is invalid FOR switch in both CMD and TCC.
| CMD will print "/q was unexpected at this time." and back to prompt.
|
| but TCC will execute "echo done".

Yes, TCC is designed for easier debugging, and it will try to execute the
whole program even in the presense of errors. If you want to quit your batch
program on the first error, insert the command
on errormsg cancel
to display the error message and return to interactive operation.
--
HTH, Steve
 

rconn

Administrator
Staff member
May 14, 2008
12,316
148
> in CMD, syntex error of internal command will break the script.
> for example:
>
> Code:
> ---------
> @echo off
> for /q %%i in (.) do echo %%i
> echo done
> ---------
> /q is invalid FOR switch in both CMD and TCC.
> CMD will print "/q was unexpected at this time." and back to prompt.
>
> but TCC will execute "echo done".

That would seem to be a CMD.EXE bug/undocumented feature (and it does not
behave this way in all versions of CMD.EXE).

I don't see any benefit in duplicating this behavior in TCC. (Particularly
since it'll break existing batch files that are using ON ERROR.)

Rex Conn
JP Software
 
Apr 1, 2010
43
0
That would seem to be a CMD.EXE bug/undocumented feature (and it does not
behave this way in all versions of CMD.EXE).

I don't see any benefit in duplicating this behavior in TCC. (Particularly
since it'll break existing batch files that are using ON ERROR.)

Rex Conn
JP Software
but from my testing, this feature exists in NT 3.51/4.0/2000/XP.
I don't have windows newer than XP so I can't test.
 

rconn

Administrator
Staff member
May 14, 2008
12,316
148
> ---Quote (Originally by rconn)---
> That would seem to be a CMD.EXE bug/undocumented feature (and it does
> not
> behave this way in all versions of CMD.EXE).
>
> I don't see any benefit in duplicating this behavior in TCC.
> (Particularly
> since it'll break existing batch files that are using ON ERROR.)
>
> Rex Conn
> JP Software
> ---End Quote---
> but from my testing, this feature exists in NT 3.51/4.0/2000/XP.
> I don't have windows newer than XP so I can't test.

I wouldn't characterize it as a "feature".

And if TCC were to duplicate this behavior, it would render the batch
debugger useless (which probably wouldn't make most users especially
happy!).

Rex Conn
JP Software
 
Apr 1, 2010
43
0
as TCC/LE doesn't have debugger, and ON ERRORMSG can't handle for just specified command(CMD breaks on syntex error with FOR and IF only). I will still think it is nice to have option/enhance ON command to enable this feature.
 
Apr 1, 2010
43
0
But not e.g. SET or DIR? That sounds like a bug to me!
But I will think this is a "safety measure" because if we just think invalid for/if statement the same as non reachable statement and continue to run the script, wrong result will happen.
 
Similar threads
Thread starter Title Forum Replies Date
S Debugger keeps breaking with no break point set. Support 1
Phileosophos Did enumservers break? Support 5
A v25 BC break in WINDOW and ACTIVATE Support 12
fromano Break on buying TextPipe Pro Support 2
C View Print Wrap - please break at whitespace Support 3
C Output continues after Ctrl-Break Support 8
vefatica ON BREAK (con't) Support 1
vefatica ON BREAK doesn't always work Support 23
J Copy from HTTP can break Support 3
E Line break in msgbox text Support 3
p.f.moore Bug in plugin break handling? Support 0
Joe Caverly SCRIPT and GetObject Support 3
vefatica SCRIPT ... TCC disappears Support 2
T How can I send a simple parameter to a script, in tc 25? Support 2
vefatica PSHELL: How pass arguments to script? Support 15
EDerH Powershell call from script Support 24
Joe Caverly .PS1 script does not work with PSHELL Support 11
MickeyF running program from script and (not) returning to script Support 12
T Fixed Echo randomly activated in script Support 4
fpefpe How to? script error Support 1
fpefpe How to? script error Support 0
vefatica @SCRIPT bug persists Support 4
D Catching the result of an evaluated script expression Support 0
Joe Caverly Non-conforming @Script Support 6
M The Matrix: a useless script ... Support 5
fpefpe How to? LUA script Support 0
T Change language in script Support 4
Steve Pitts Documentation Script errors invoking help Support 15
R How to? Launch and execute commands in tcmd.exe through MSBuild Script. Support 3
Joe Caverly @SCRIPT does not like all comments Support 2
Mordachai Help! How to set parameters for script I'm debugging?! Support 6
fpefpe How to? Script support Support 8
JohnQSmith "SCRIPT" Support 7
rconn Script kiddies on the attack Support 4
krischik Stop Script after Syntax Error. Support 6
H Ruby - Running External Ruby script crashes TCC Support 11
Joe Caverly SCRIPT Command Support 2
T Obfuscating passwords in script Support 14
Stefano Piccardi IDE.exe start toobar button fails when % in script path Support 0
lassevk exit(1) in a python script exits console, by design or bug? Support 1
K iftp script copy deletes target files Support 17
R script problem with mapped network drive Support 1

Similar threads