• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

break script on syntex error

Apr 1, 2010
43
0
#1
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".
 
#2
| 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
10,318
93
#3
> 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
#4
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
10,318
93
#5
> ---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
#6
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.
 
Top Bottom