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