Page 1 of 1

Docs: GOTO Bug Clarification

Posted: 27 Aug 2024 06:31
by lmstearn
Hi, in the goto docs bug section there is:
GOTO breaks the & and && redirection operators.
Does this apply to either the line, sub or entire script?
Thanks.

Re: Docs: GOTO Bug Clarification

Posted: 27 Aug 2024 09:16
by aGerman
SS64 is for sure not the official docs. So you may ask the author of the site to disambiguate their statement.
IMO it refers to & and && following a GOTO command. However, I would consider this to be expected behavior rather than a bug.

Steffen

Re: Docs: GOTO Bug Clarification

Posted: 27 Aug 2024 10:07
by lmstearn
Thanks for the HU, yes, if not the official, my personal "official" goto for years now. :)

Re: Docs: GOTO Bug Clarification

Posted: 27 Aug 2024 11:50
by aGerman
Yeah, to be clear - SS64 is a pretty good reference. The official MS docs don't tell you about such effects of GOTO. However, I still think that "bug" is the wrong wording here. Just an example of how I understand it:

Code: Select all

@echo off
goto label&echo FOO

:label
echo BAR

pause
FOO is never printed as the GOTO makes the program jump to :label earlier. That's exactly how I'd expect it to work.

Steffen

Re: Docs: GOTO Bug Clarification

Posted: 27 Sep 2024 16:10
by GeoffVass
Agreed, goto is an immediate change of program flow. If you wanted to recast that script to do something and then come back and do something else, use functions:

Code: Select all

@echo off
call :label&echo FOO

goto End

:label
echo BAR
goto :EOF

:End
pause