1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Usage:
|
4 | # ./declare.sh <function name>
|
5 |
|
6 | set -o nounset
|
7 | set -o pipefail
|
8 | set -o errexit
|
9 |
|
10 | demo() {
|
11 | readonly __ONE=bar # declare -r
|
12 | export readonly __TWO=bar # declare -x
|
13 | export readonly local __THREE=bar # declare -x
|
14 | readonly __FOUR=bar
|
15 | export __FOUR # declare -rx
|
16 | # OK export readonly doesn't work! That was silly.
|
17 | # not sure why I thought they can be combined.
|
18 |
|
19 | # Show everything
|
20 | declare -p | grep __
|
21 | }
|
22 |
|
23 | demo-clean() {
|
24 | # Show a clean demo
|
25 | env -i $0 demo
|
26 | }
|
27 |
|
28 | "$@"
|