/
hubbitus
/
shell.scripts
Обзор
Документация
Войти
/
hubbitus
/
shell.scripts
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
SHARED/goto.bash
39 строк
572 B
Hubbitus
Borrow goto bash emulation script: http://bobcopeland.com/blog/2012/10/goto-in-bash/
07 июл 2015, 18:45
07 июл 2015, 18:45
922dedd
Код
Авторство
О чём код?
#!/bin/bash # Borrowed from http://bobcopeland.com/blog/2012/10/goto-in-bash/ (only function renamed to goto) and slightly modified. # include this boilerplate function goto(){ label=$1 cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$') eval "$cmd" exit } #start=${1:-"start"} # #goto $start # #start: ## your script goes here... #x=100 #goto foo # #mid: #x=101 #echo "This is not printed!" # #foo: #x=${x:-10} #echo x is $x # #results should be: # # #$ ./test.sh #x is 100 #$ ./test.sh foo #x is 10 #$ ./test.sh mid #This is not printed! #x is 101