Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Why is the exit code zero?

May
855
0
Here is the transcript of a complete TCC session:
Code:
   Sun  Dec 9, 2012   2:46:31a
SafeChars plugin v1.7.0 loaded.
TCC  14.02.38 x64   Windows 7 [Version 6.1.7601]
Copyright 2012 JP Software Inc.  All Rights Reserved
Registered to Daniel Mathews
[Z:\]Type TestQuit.btm
@Echo Off
Quit 8
[Z:\]TestQuit
[Z:\]Echo %? %_?
0 0
[Z:\]TestQuit
[Z:\]Echo %_? %?
0 0
[Z:\]
As you can see the batch file "TestQuit.btm" does nothing more than exit with an exit code of 8. I ran TestQuit twice showing %? and %_? in both orders to absolutely prove that echoing one was not zeroing the other.

I must be really stupid or something because I'm too stupid to figure out why the exit code is always zero when the batch file does nothing more than quit with a hard-coded exit code of 8.
 
Code:
(system)  C:\...\TCMD14x64 >echo quit 8 > testquit.btm
 
(system)  C:\...\TCMD14x64 >testquit.btm
quit 8
 
(system)  C:\...\TCMD14x64 >echo %? %_?
8 0
 
(system)  C:\...\TCMD14x64 >testquit.btm
quit 8
 
(system)  C:\...\TCMD14x64 >echo %_? %?
0 8
 
(system)  C:\...\TCMD14x64 >
Not reproducible here. Try unloading all plugins.
 
Thank you for looking at it, Frank, but no go. I get the same result(s) with no plugins loaded! Transcript:
Code:
[Z:\]:: For Reference
[Z:\]type TestQuit.btm
@Echo Off
Quit 8
[Z:\]Plugin /u *
[Z:\]TestQuit
[Z:\]Echo %? %_?
0 0
[Z:\]
I have to be honest here and say in my frustration: I get so tired of fighting weird problems!!!!!
 
I have to be honest here and say in my frustration: I get so tired of fighting weird problems!!!!!
Yes, no fun.
I just updated to the latest version TCC 14.03.52 x64, but still get the correct returncode like in my post above.
 
Charles, I made a posting at evidently almost the same time as Frank did, and mine has disappeared. So redoing it, the answer is that I was running a batch file specified by a "POST_EXEC" alias, and said batch file was destroying both exit codes. This has an easy workaround for the external program's exit code (%?), namely saving it on entry to the routine and restoring it (via a "Quit" command) on exit from the routine, and while it is almost certainly possible to save the internal command's exit code (%_?) on entry to the POST_EXEC routine, I know of no way to reset it at the end of that routine. The only solution that I can see, which is not completely satisfactory, is to run a batch file that is specified by a "PRE_EXEC" alias.
 
Back
Top
[FOX] Ultimate Translator
Translate