Created
May 21, 2016 23:30
-
-
Save farindra/56f280209bee1e04ec5a2f3fbd43012b to your computer and use it in GitHub Desktop.
Fungi GOTO Label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function jumpto | |
{ | |
label=$1 | |
cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$') | |
eval "$cmd" | |
exit | |
} | |
start=${1:-"start"} | |
jumpto $start | |
start: | |
# your script goes here... | |
x=100 | |
jumpto foo | |
mid: | |
x=101 | |
echo "This is not printed!" | |
foo: | |
x=${x:-10} | |
echo x is $x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment