1 | #!/usr/bin/env bash |
2 | |
3 | set -o nounset |
4 | set -o pipefail |
5 | set -o errexit |
6 | |
7 | f1() { |
8 | local foo=bar |
9 | foo=1 # can modify it now |
10 | echo $foo |
11 | |
12 | readonly foo # not anymore |
13 | #foo=2 # would cause an exception |
14 | echo $foo |
15 | |
16 | echo done |
17 | |
18 | # This is a GLOBAL, not a local |
19 | readonly f1_readonly=f1_readonly |
20 | } |
21 | |
22 | f1 |
23 | |
24 | echo $f1_readonly |