1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Usage:
|
4 | # ./01-char-class.sh <function name>
|
5 |
|
6 | set -o nounset
|
7 | set -o pipefail
|
8 | set -o errexit
|
9 |
|
10 | demo() {
|
11 | [[ a == [a] ]]
|
12 | [[ a != [^a] ]]
|
13 |
|
14 | [[ a == [ab] ]]
|
15 | [[ a != [^ab] ]]
|
16 |
|
17 | [[ a == [[:alpha:]] ]]
|
18 | [[ a != [^[:alpha:]] ]]
|
19 | [[ 0 == [^[:alpha:]] ]]
|
20 |
|
21 | # NOTE: there is only one negation. You can't mix them.
|
22 | [[ 0 == [^[:alpha:]] ]]
|
23 |
|
24 | if test -n "${BASH_VERSION:-}"; then
|
25 | #echo hi
|
26 | true
|
27 | fi
|
28 |
|
29 | echo
|
30 | echo 'ALL PASSED'
|
31 | }
|
32 |
|
33 | "$@"
|