The following batch file shows an issue with "gosub label > file"; TCC prints a command log to the file instead of printing the output of the labeled sub-routine. The first "gosub EMIT1" is sufficient to show the issue, the rest of the script simply tries variations of gosub syntax.
Although I also tried - to no avail - enclosing gosub within brackets the help file explicitly says that gosub can't be used in a command group. It doesn't say (I couldn'd find) that gosub can't be redirected.
I tested TCC 14.00.31, TCC 13.04.63, TCCLE 13.04.63 on WinXP SP3 x32 and Win7 SP1 x32. All tested versions are affected. If this indeed turns out to be a bug to be fixed, would you please fix TCCLE as well? Thank you.
issue.btm:
output:
Although I also tried - to no avail - enclosing gosub within brackets the help file explicitly says that gosub can't be used in a command group. It doesn't say (I couldn'd find) that gosub can't be redirected.
I tested TCC 14.00.31, TCC 13.04.63, TCCLE 13.04.63 on WinXP SP3 x32 and Win7 SP1 x32. All tested versions are affected. If this indeed turns out to be a bug to be fixed, would you please fix TCCLE as well? Thank you.
issue.btm:
Code:
setlocal
gosub EMIT1 a1 > issue1.txt
call :EMIT2 a2 > issue2.txt
gosub "%_batchname" EMIT1 a3 > issue3.txt
type issue1.txt
echo ---
type issue2.txt
echo ===
type issue3.txt
echo ***
endlocal
quit
:EMIT1 [a]
rem gosub [batchname] EMIT1 > FILE prints command log to FILE
rem istead of printing the output of EMIT1
echo (%a) foo
return
:EMIT2 [a]
rem CMD-compatible subroutine
rem same issue as gosub EMIT1
echo (%a) bar
quit
Code:
V:\temp>issue.btm
setlocal
gosub EMIT1 a1 > issue1.txt
call :EMIT2 a2 > issue2.txt
gosub "V:\temp\issue.btm" EMIT1 a3 > issue3.txt
type issue1.txt
rem gosub [batchname] EMIT1 > FILE prints command log to FILE
rem istead of printing the output of EMIT1
echo (a1) foo
(a1) foo
return
echo ---
---
type issue2.txt
rem CMD-compatible subroutine
rem same issue as gosub EMIT1
echo () bar
() bar
quit
echo ===
===
type issue3.txt
rem gosub [batchname] EMIT1 > FILE prints command log to FILE
rem istead of printing the output of EMIT1
echo (a3) foo
(a3) foo
return
echo ***
***
endlocal
quit