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