Welcome!

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

SignUp Now!

goto compat issue makes all node/npm wrapper scripts fail to run...

Sep
32
1
goto does not seem to set error code status.

Code:
goto Really 2>NUL || echo ... Yeah... Really

Under TCC (28.01.14 x64 - but happening for a long time) this batch file will only print 'Really'.

Run with cmd and the RHS of the || executes.

For reference here is the scenario.
Any command line tool install with npm for a node project will install a .cmd wrapper. That .cmd wrapper will have a line that does the final tool exec like this one for the typescript compiler):

Code:
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%"  "%dp0%\node_modules\typescript\bin\tsc" %*

I'm guessing they do the goto as a hack to clear/set the last error status to a predictable value. <shrug>

I don't think any of the compat settings address this. I'd love a work around better than a script that hacks at all these other scripts. :(
 
This is two CMD bugs and a drunken programmer who was trying (failing) to be clever instead of doing things the normal & documented way.

GOTO in CMD does not set ERRORLEVEL; it's always 0 whether it succeeded or failed. The || is there because the CMD parser doesn't realize that the failed GOTO has already aborted the batch file.

This is similar (but not identical) to the CMD IF bug that the DupBugs TCMD.INI directive addresses. I've added a similar kludge for the next v28 build to check for a "GOTO xxx || yyy" construct when DupBugs is set.

But somebody still needs to take away that developer's computer.
 
Thanks Rex - great news that you are doing a work-around.

And then... Wow... That gen'd code for node is even more craptastic than I thought. :/
 

Similar threads

Back
Top