1 # @( conflict
2
3 #### extglob
4 shopt -s extglob
5
6 [[ foo.py == @(*.sh|*.py) ]]
7 echo status=$?
8
9 # Synonym. This is a syntax error in bash.
10 [[ foo.py == ,(*.sh|*.py) ]]
11 echo status=$?
12
13 ## STDOUT:
14 status=0
15 status=0
16 ## END
17
18 #### split command sub @() in expression mode
19 shopt --set parse_proc parse_at
20
21 var x = @(seq 3)
22
23 write -- @x
24 ## STDOUT:
25 1
26 2
27 3
28 ## END
29
30 #### split command sub @() in command mode
31
32 shopt -s parse_at
33 write -- @(seq 3)
34
35 echo --
36 IFS=x
37 x=axbxxc
38 argv.py $x
39
40 # This construct behaves the same with simple_word_eval on
41 echo --
42 shopt -s simple_word_eval
43 write -- @(seq 3)
44
45
46 echo --
47 write -- @(echo axbxxc)
48
49 ## STDOUT:
50 1
51 2
52 3
53 --
54 ['a', 'b', '', 'c']
55 --
56 1
57 2
58 3
59 --
60 a
61 b
62
63 c
64 ## END
65
66 #### Idiomatic for loop using @(seq $n)
67 shopt -s oil:upgrade
68
69 for x in @(seq 3) {
70 echo "[$x]"
71 }
72 for x in @(seq 3) {
73 argv.py z [$x] # note this is an empty glob!!!
74 }
75 ## STDOUT:
76 [1]
77 [2]
78 [3]
79 ['z']
80 ['z']
81 ['z']
82 ## END
83
84 #### @() can't start in the middle of the word
85 shopt -s extglob # this makes it match in bash
86 shopt -s oil:upgrade
87
88 # This is currently a RUNTIME error when simple_word_eval is on
89
90 touch foo.py
91 echo f@(*.py)
92 ## status: 1
93 ## STDOUT:
94 ## END
95 ## OK bash status: 0
96 ## OK bash STDOUT:
97 foo.py
98 ## END
99
100 #### @() can't have any tokens after it
101 shopt -s oil:upgrade
102
103 write -- @(seq 2)
104 write -- @(seq 3)x
105 ## status: 2
106 ## STDOUT:
107 1
108 2
109 ## END