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