fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes Altmanningertests: filter control sequences only when interactive1e858eae3

master
4.5 KiB204 linesraw
1#RUN: %fish %s
2
3# pipestatus variable - builtins only
4false | false | false
5echo $pipestatus : $status
6#CHECK: 1 1 1 : 1
7true | true | true
8echo $pipestatus : $status
9#CHECK: 0 0 0 : 0
10false | true | false
11echo $pipestatus : $status
12#CHECK: 1 0 1 : 1
13true | false | true
14echo $pipestatus : $status
15#CHECK: 0 1 0 : 0
16
17# pipestatus variable - no builtins
18# Note: On some systems `command false` fails with 255, not 1. We allow both.
19command false | command false | command false
20echo $pipestatus : $status
21#CHECK: {{1|255}} {{1|255}} {{1|255}} : {{1|255}}
22command true | command true | command true
23echo $pipestatus : $status
24#CHECK: 0 0 0 : 0
25command false | command true | command false
26echo $pipestatus : $status
27#CHECK: {{1|255}} 0 {{1|255}} : {{1|255}}
28command true | command false | command true
29echo $pipestatus : $status
30#CHECK: 0 {{1|255}} 0 : 0
31
32# pipestatus variable - mixed
33command false | command false | false
34echo $pipestatus : $status
35#CHECK: {{1|255}} {{1|255}} 1 : 1
36command true | true | command true
37echo $pipestatus : $status
38#CHECK: 0 0 0 : 0
39false | command true | command false
40echo $pipestatus : $status
41#CHECK: 1 0 {{1|255}} : {{1|255}}
42true | false | command true
43echo $pipestatus : $status
44#CHECK: 0 1 0 : 0
45sh -c 'exit 5' | sh -c 'exit 2'
46echo $pipestatus : $status
47#CHECK: 5 2 : 2
48sh -c 'exit 3' | false | sh -c 'exit 6'
49echo $pipestatus : $status
50#CHECK: 3 1 6 : 6
51sh -c 'exit 9' | true | sh -c 'exit 3' | false
52echo $pipestatus : $status
53#CHECK: 9 0 3 1 : 1
54
55# pipestatus variable - non-pipe
56true
57echo $pipestatus : $status
58#CHECK: 0 : 0
59false
60echo $pipestatus : $status
61#CHECK: 1 : 1
62command true
63echo $pipestatus : $status
64#CHECK: 0 : 0
65command false
66echo $pipestatus : $status
67#CHECK: {{1|255}} : {{1|255}}
68sh -c 'exit 4'
69echo $pipestatus : $status
70#CHECK: 4 : 4
71
72# pipestatus variable - negate
73! true
74echo $pipestatus : $status
75#CHECK: 0 : 1
76! false
77echo $pipestatus : $status
78#CHECK: 1 : 0
79! false | false | false
80echo $pipestatus : $status
81#CHECK: 1 1 1 : 0
82! true | command true | true
83echo $pipestatus : $status
84#CHECK: 0 0 0 : 1
85! false | true | command false
86echo $pipestatus : $status
87#CHECK: 1 0 {{1|255}} : 0
88! command true | command false | command true
89echo $pipestatus : $status
90#CHECK: 0 {{1|255}} 0 : 1
91! sh -c 'exit 9' | true | sh -c 'exit 3'
92echo $pipestatus : $status
93#CHECK: 9 0 3 : 0
94
95# pipestatus variable - block
96begin
97    true
98end
99echo $pipestatus : $status
100#CHECK: 0 : 0
101begin
102    false
103end
104echo $pipestatus : $status
105#CHECK: 1 : 1
106begin
107    ! true
108end
109echo $pipestatus : $status
110#CHECK: 0 : 1
111begin
112    ! false
113end
114echo $pipestatus : $status
115#CHECK: 1 : 0
116true | begin
117    true
118end
119echo $pipestatus : $status
120#CHECK: 0 0 : 0
121false | begin
122    false
123end
124echo $pipestatus : $status
125#CHECK: 1 1 : 1
126true | begin
127    ! true
128end
129echo $pipestatus : $status
130#CHECK: 0 1 : 1
131false | begin
132    ! false
133end
134echo $pipestatus : $status
135#CHECK: 1 0 : 0
136begin
137    true | false
138end
139echo $pipestatus : $status
140#CHECK: 0 1 : 1
141begin
142    false | true
143end
144echo $pipestatus : $status
145#CHECK: 1 0 : 0
146begin
147    ! true
148end | false
149echo $pipestatus : $status
150#CHECK: 1 1 : 1
151begin
152    ! false
153end | true
154echo $pipestatus : $status
155#CHECK: 0 0 : 0
156begin
157    sh -c 'exit 3'
158end | begin
159    sh -c 'exit 5'
160end
161echo $pipestatus : $status
162#CHECK: 3 5 : 5
163begin
164    ! sh -c 'exit 3'
165end | begin
166    sh -c 'exit 5'
167end
168echo $pipestatus : $status
169#CHECK: 0 5 : 5
170begin
171    ! sh -c 'exit 3'
172end | begin
173    ! sh -c 'exit 5'
174end
175echo $pipestatus : $status
176#CHECK: 0 0 : 0
177
178# Check that failed redirections correctly handle pipestatus, etc.
179# See #7540.
180command true > /not/a/valid/path
181echo $pipestatus : $status
182#CHECK: 1 : 1
183#CHECKERR: warning: An error occurred while redirecting file '/not/a/valid/path'
184#CHECKERR: warning: Path '/not' does not exist
185
186# Here the first process will launch, the second one will not.
187command true | command true | command true > /not/a/valid/path
188echo $pipestatus : $status
189#CHECK: 0 0 1 : 1
190#CHECKERR: warning: An error occurred while redirecting file '/not/a/valid/path'
191#CHECKERR: warning: Path '/not' does not exist
192
193# Pipeline breaks do not result in dangling jobs.
194command true | command cat > /not/a/valid/path ; jobs
195#CHECKERR: warning: An error occurred while redirecting file '/not/a/valid/path'
196#CHECKERR: warning: Path '/not' does not exist
197#CHECK: jobs: There are no jobs
198
199# Regression test for #7038
200cat /dev/zero | dd > /not/a/valid/path
201echo 'Not hung'
202#CHECKERR: warning: An error occurred while redirecting file '/not/a/valid/path'
203#CHECKERR: warning: Path '/not' does not exist
204#CHECK: Not hung