1 |
# |
2 |
# Tests nocasematch matching |
3 |
|
4 |
#### [[ equality matching |
5 |
shopt -s nocasematch |
6 |
[[ a == A ]]; echo $? |
7 |
[[ A == a ]]; echo $? |
8 |
[[ A == [a] ]]; echo $? |
9 |
[[ a == [A] ]]; echo $? |
10 |
## STDOUT: |
11 |
0 |
12 |
0 |
13 |
0 |
14 |
0 |
15 |
## END |
16 |
|
17 |
#### [[ regex matching |
18 |
shopt -s nocasematch |
19 |
[[ a =~ A ]]; echo $? |
20 |
[[ A =~ a ]]; echo $? |
21 |
[[ a =~ [A] ]]; echo $? |
22 |
[[ A =~ [a] ]]; echo $? |
23 |
## STDOUT: |
24 |
0 |
25 |
0 |
26 |
0 |
27 |
0 |
28 |
## END |
29 |
|
30 |
#### [ matching |
31 |
shopt -s nocasematch |
32 |
[ a = A ]; echo $? |
33 |
[ A = a ]; echo $? |
34 |
## STDOUT: |
35 |
1 |
36 |
1 |
37 |
## END |
38 |
|
39 |
#### case matching |
40 |
shopt -s nocasematch |
41 |
case a in A) echo 0 ;; *) echo 1 ;; esac |
42 |
case A in a) echo 0 ;; *) echo 1 ;; esac |
43 |
case a in [A]) echo 0 ;; *) echo 1 ;; esac |
44 |
case A in [a]) echo 0 ;; *) echo 1 ;; esac |
45 |
## STDOUT: |
46 |
0 |
47 |
0 |
48 |
0 |
49 |
0 |
50 |
## END |
51 |
|
52 |
#### file matching |
53 |
shopt -s nocasematch |
54 |
touch a B |
55 |
echo [A] [b] |
56 |
## STDOUT: |
57 |
[A] [b] |
58 |
## END |
59 |
|
60 |
#### parameter expansion matching |
61 |
shopt -s nocasematch |
62 |
foo=a |
63 |
bar=A |
64 |
echo "${foo#A}" "${foo#[A]}" |
65 |
echo "${bar#a}" "${bar#[a]}" |
66 |
## STDOUT: |
67 |
a a |
68 |
A A |
69 |
## END |