[Info-vax] /END=label
Simon Clubley
clubley at remove_me.eisner.decus.org-Earth.UFP
Mon Aug 27 19:44:31 EDT 2018
On 2018-08-27, John Reagan <xyzzy1959 at gmail.com> wrote:
>
> Can you give an example? I can't figure out how you'd do that. I'll let you choose the shell.
>
> #!/bin/bash
> ./a.out # C program that does something and then jumps to label
> l1:
> l2:
> l3:
>
>
> bash doesn't even have a 'goto' and people have to resort to using case statements to case on the result (no different than looking at $STATUS and IF/THEN/ELSE'ing on the result)
Actually, bash does at least have a computed goto (or more accurately,
a computed call as you return back to where you started). Try something
along the lines of:
./program_to_run
label$?
where label1, label2, etc, are functions instead of the labels you
use above. You then exit the program with the appropriate exit status.
The only other possibility I can think of is to use the trap command
to setup commands to run and then generate a signal from within the
program.
However, both of these options still means you need _something_ in
the shell script so it's not a match for what was being asked.
BTW, I hope no-one ever asks me to review code that uses either of
these techniques for control purposes. :-) There's a reason why I would
like to see control structures in DCL...
Simon.
--
Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980s technology to a 21st century world
More information about the Info-vax
mailing list