[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash RFE: Goto (especially for jumping while debugging)
From: |
Richard Neill |
Subject: |
Re: Bash RFE: Goto (especially for jumping while debugging) |
Date: |
Mon, 22 Sep 2008 23:18:18 +0100 |
User-agent: |
Thunderbird 2.0.0.16 (X11/20080725) |
Bob Proulx wrote:
Richard Neill wrote:
Dear All,
In the future please start a new message for a new thread of
discussion. When you reply to old messages from three months ago
those of us who actually keep months worth of email see the message
threaded with the previous discussion about variables and subshells.
If anyone has killed that thread then the continuation is also killed.
D'oh! Sorry about that. I had always thought that editing the subject
line was what changed the thread, rather than some internal state
variable in the mail-client. I stand corrected. BTW, doesn't bash have
a bugzilla?
Here's a rather controversial request, namely that bash should support
'goto'.
Although goto does have uses it is definitely a keyword of the
damned.
cat >/dev/null <<'label_foo' ... LABEL
This has exactly the same effect.
I actually was going to reply and suggest exactly the above. But then
realized you had already suggested it.
That does work. Actually, maybe the way is to define a function called
"goto", which handles the common case of a forward jump.
Normally I would do a commented out section. Easy and non-controversial.
Or I would do if false; then...fi
No good if one wants to jump over/out-of a control structure.
For just a comment section this doesn't seem to be a compelling need.
For that you would need to show how writing state-machines or
something is so much easier or some such...
I think existing functionality would work. Given that 'goto' would
intentionally over-ride all other control structures, then I can suggest
2 ways this might be implemented:
i. Treat goto as "exit", but don't clean up variables and functions.
Then, go back to the start, skipping all instructions till LABEL.
Doing it this way means that goto quits out of all nested control
structures.
ii. Source $0, but skip all instructions till LABEL.
Doing it this way means that goto does not quit out of any nested
control structures.
Best wishes,
Richard