Debian Codegraph @

ind-func.sh

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