I am looking for a equivalent of 'goto' or 'jump' in the Bourne shell.
The reason is that I want to have a unique returning point for each of
my functions. At the moment they are stuffed with many 'returns' and I
can't debug that.
Gael.
The reason is that I want to have a unique returning point for each of
my functions. At the moment they are stuffed with many 'returns' and I
can't debug that.
Gael.
>The reason is that I want to have a unique returning point for each of
>my functions. At the moment they are stuffed with many 'returns' and I
>can't debug that.
result=1 ; goto r # return 1
.
.
.
result=2 ; goto r # return 2
.
.
.
r: return $result
any clearer than this:
return 1 # return 1
.
.
.
return 2 # return 2
?
Is that what you're trying to do?
If you really hate multiple exit points, then fix the code so that its
structure doesn't need them. For example, change this:
if [ "$x" -gt 2 ]
then
return 0
fi
return 1
to this:
if [ "$x" -gt 2 ]
then
result=0
else
result=1
fi
return $result
Hope that helps.
- Logan
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos
> I am looking for a equivalent of 'goto' or 'jump' in the Bourne shell.
There is no "goto" in the Bourne shell.
> The reason is that I want to have a unique returning point for each of
> my functions. At the moment they are stuffed with many 'returns' and I
> can't debug that.
If your aim is to improve your code, you could post parts of
If you cannot see, which "return" terminates the function,
you could try to invoke your script using the following
command:
$ sh -vx script
or
$ ksh -vx script
Heiner
--
___ _
\__ \ _/ -_) V / -_) ' \ Shell Script Programmers: visit
|___/\__\___|\_/\___|_||_| http://www.shelldorado.com/
1. What are these "Something Wicked happened!" messages
I'm using the 2.2.5 kernel that comes with RedHat 6.0 and everynow and then I
see a series of these messages:
eth1: Something Wicked happened! 000a
Sometimes it's 000b
eth1 is a D-Link DFE-530TX using the via-rhine module. Does anyone know what
these messages mean?
Regards,
Ying
2. some question in encrypt password
3. wicked 3d
7. eth0: Something Wicked happened
9. pppoe - something wicked happened
12. HELP! Something Wicked happened!
13. wicked csh commandline problem