| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # ind-func.sh: Passing an indirect reference to a function. |
| 3 | |
| 4 | echo_varscip-shell shell abs-guide 10-4 echo_var(). () |
| 5 | { |
| 6 | echoscip-shell system . . echo. "$1" |
| 7 | } |
| 8 | |
| 9 | message=Hello |
| 10 | Hello=Goodbye |
| 11 | |
| 12 | echo_varscip-shell shell abs-guide 10-4 echo_var(). "$message" # Hello |
| 13 | # Now, let's pass an indirect reference to the function. |
| 14 | echo_varscip-shell shell abs-guide 10-4 echo_var(). "${!message}" # Goodbye |
| 15 | |
| 16 | echoscip-shell system . . echo. "-------------" |
| 17 | |
| 18 | # What happens if we change the contents of "hello" variable? |
| 19 | Hello="Hello, again!" |
| 20 | echo_varscip-shell shell abs-guide 10-4 echo_var(). "$message" # Hello |
| 21 | echo_varscip-shell shell abs-guide 10-4 echo_var(). "${!message}" # Hello, again! |
| 22 | |
| 23 | exit 0 |