Goto is allowed only when the shell is taking commands from a seekable
command file (see lseek(2)).
The entire command file is searched for a line beginning with a
: as the first non-blank character, followed by one or more blanks,
and then the label. If such a line is found, goto repositions
the command-file offset to the line after the label and exits. This causes
the shell to transfer to the labelled line.
: is a special command which causes the shell to do
nothing.
The goto command exits with one of the following values:
- 0
- The label was found.
- 1
- The label was not found.
- 2
- An error was detected.
if(1), etsh(1), tsh(1)
Etsh home page: https://etsh.nl/
The goto command from Version 6 (V6) UNIX requires : to be the
first character on the labelled line. Otherwise, the label cannot be found.
This port differs in that : may be preceded by blanks. This
allows labelled lines to be indented so that complex command files might be
easier to read and understand.
A goto command appeared as /bin/goto in Version 3 (V3) UNIX.
This port of the goto command is derived from Version 6 (V6) UNIX
/usr/source/s1/goto.c. It was written by Ken Thompson of Bell Labs. Jeffrey
Allen Neitzel <jan@etsh.nl> ported and maintains it as
goto(1).
See either the LICENSE file which is distributed with etsh or
https://etsh.nl/license/ for full details.