Skip to content

Instantly share code, notes, and snippets.

@farindra
Created May 21, 2016 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farindra/56f280209bee1e04ec5a2f3fbd43012b to your computer and use it in GitHub Desktop.
Save farindra/56f280209bee1e04ec5a2f3fbd43012b to your computer and use it in GitHub Desktop.
Fungi GOTO Label
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