| Line | |
|---|
| 1 | #!../bash
|
|---|
| 2 | #
|
|---|
| 3 | # Test correct trap return codes = 2 means skip execution.
|
|---|
| 4 | shopt -s extdebug
|
|---|
| 5 | print_trap() {
|
|---|
| 6 | echo "lineno: $1 ($LINENO) ${FUNCNAME[1]}"
|
|---|
| 7 | if [[ $debug_exit == 2 ]] ; then
|
|---|
| 8 | debug_exit=0
|
|---|
| 9 | return 2
|
|---|
| 10 | fi
|
|---|
| 11 | return 0
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | debug_exit=0
|
|---|
| 15 | trap 'print_trap $LINENO' DEBUG
|
|---|
| 16 |
|
|---|
| 17 | x=1
|
|---|
| 18 | echo "x is $x"
|
|---|
| 19 | debug_exit=2
|
|---|
| 20 | x=2
|
|---|
| 21 | echo "x is $x"
|
|---|
| 22 |
|
|---|
| 23 | #;;; Local Variables: ***
|
|---|
| 24 | #;;; mode:shell-script ***
|
|---|
| 25 | #;;; eval: (sh-set-shell "bash") ***
|
|---|
| 26 | #;;; End: ***
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.