2020-02-07 20:49:42 +01:00
#RUN: %fish %s
2019-02-24 21:45:59 -08:00
2020-02-07 20:49:42 +01:00
# pipestatus variable - builtins only
2020-03-09 19:36:12 +01:00
false | false | false
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 1 1 1 : 1
2020-03-09 19:36:12 +01:00
true | true | true
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 0 0 : 0
2020-03-09 19:36:12 +01:00
false | true | false
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 1 0 1 : 1
2020-03-09 19:36:12 +01:00
true | false | true
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 1 0 : 0
2019-02-24 21:45:59 -08:00
2020-02-07 20:49:42 +01:00
# pipestatus variable - no builtins
2020-02-12 19:46:28 +01:00
# Note: On some systems `command false` fails with 255, not 1. We allow both.
2020-03-09 19:36:12 +01:00
command false | command false | command false
echo $pipestatus : $status
2021-06-24 18:14:45 +02:00
#CHECK: {{1|255}} {{1|255}} {{1|255}} : {{1|255}}
2020-03-09 19:36:12 +01:00
command true | command true | command true
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 0 0 : 0
2020-03-09 19:36:12 +01:00
command false | command true | command false
echo $pipestatus : $status
2021-06-24 18:14:45 +02:00
#CHECK: {{1|255}} 0 {{1|255}} : {{1|255}}
2020-03-09 19:36:12 +01:00
command true | command false | command true
echo $pipestatus : $status
2020-02-12 19:46:28 +01:00
#CHECK: 0 {{1|255}} 0 : 0
2019-02-24 21:45:59 -08:00
2020-02-07 20:49:42 +01:00
# pipestatus variable - mixed
2020-03-09 19:36:12 +01:00
command false | command false | false
echo $pipestatus : $status
2020-02-12 19:46:28 +01:00
#CHECK: {{1|255}} {{1|255}} 1 : 1
2020-03-09 19:36:12 +01:00
command true | true | command true
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 0 0 : 0
2020-03-09 19:36:12 +01:00
false | command true | command false
echo $pipestatus : $status
2021-06-24 18:14:45 +02:00
#CHECK: 1 0 {{1|255}} : {{1|255}}
2020-03-09 19:36:12 +01:00
true | false | command true
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 1 0 : 0
2020-03-09 19:36:12 +01:00
sh -c 'exit 5' | sh -c 'exit 2'
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 5 2 : 2
2020-03-09 19:36:12 +01:00
sh -c 'exit 3' | false | sh -c 'exit 6'
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 3 1 6 : 6
2020-03-09 19:36:12 +01:00
sh -c 'exit 9' | true | sh -c 'exit 3' | false
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 9 0 3 1 : 1
2019-02-24 21:45:59 -08:00
2020-02-07 20:49:42 +01:00
# pipestatus variable - non-pipe
2020-03-09 19:36:12 +01:00
true
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 : 0
2020-03-09 19:36:12 +01:00
false
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 1 : 1
2020-03-09 19:36:12 +01:00
command true
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 : 0
2020-03-09 19:36:12 +01:00
command false
echo $pipestatus : $status
2021-06-24 18:14:45 +02:00
#CHECK: {{1|255}} : {{1|255}}
2020-03-09 19:36:12 +01:00
sh -c 'exit 4'
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 4 : 4
2019-02-24 21:45:59 -08:00
2020-02-07 20:49:42 +01:00
# pipestatus variable - negate
2020-03-09 19:36:12 +01:00
! true
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 : 1
2020-03-09 19:36:12 +01:00
! false
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 1 : 0
2020-03-09 19:36:12 +01:00
! false | false | false
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 1 1 1 : 0
2020-03-09 19:36:12 +01:00
! true | command true | true
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 0 0 : 1
2020-03-09 19:36:12 +01:00
! false | true | command false
echo $pipestatus : $status
2020-02-12 19:46:28 +01:00
#CHECK: 1 0 {{1|255}} : 0
2020-03-09 19:36:12 +01:00
! command true | command false | command true
echo $pipestatus : $status
2020-02-12 19:46:28 +01:00
#CHECK: 0 {{1|255}} 0 : 1
2020-03-09 19:36:12 +01:00
! sh -c 'exit 9' | true | sh -c 'exit 3'
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 9 0 3 : 0
2019-02-24 21:45:59 -08:00
2020-02-07 20:49:42 +01:00
# pipestatus variable - block
2020-03-09 19:36:12 +01:00
begin
true
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 : 0
2020-03-09 19:36:12 +01:00
begin
false
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 1 : 1
2020-03-09 19:36:12 +01:00
begin
! true
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 : 1
2020-03-09 19:36:12 +01:00
begin
! false
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 1 : 0
2020-03-09 19:36:12 +01:00
true | begin
true
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 0 : 0
2020-03-09 19:36:12 +01:00
false | begin
false
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 1 1 : 1
2020-03-09 19:36:12 +01:00
true | begin
! true
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 1 : 1
2020-03-09 19:36:12 +01:00
false | begin
! false
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 1 0 : 0
2020-03-09 19:36:12 +01:00
begin
true | false
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 1 : 1
2020-03-09 19:36:12 +01:00
begin
false | true
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 1 0 : 0
2020-03-09 19:36:12 +01:00
begin
! true
end | false
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 1 1 : 1
2020-03-09 19:36:12 +01:00
begin
! false
end | true
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 0 : 0
2020-03-09 19:36:12 +01:00
begin
sh -c 'exit 3'
end | begin
sh -c 'exit 5'
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 3 5 : 5
2020-03-09 19:36:12 +01:00
begin
! sh -c 'exit 3'
end | begin
sh -c 'exit 5'
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 5 : 5
2020-03-09 19:36:12 +01:00
begin
! sh -c 'exit 3'
end | begin
! sh -c 'exit 5'
end
echo $pipestatus : $status
2020-02-07 20:49:42 +01:00
#CHECK: 0 0 : 0
2020-12-13 17:01:06 -08:00
# 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'
2021-11-19 21:11:28 +01:00
#CHECKERR: warning: Path '/not' does not exist
2020-12-13 17:01:06 -08:00
# 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'
2021-11-19 21:11:28 +01:00
#CHECKERR: warning: Path '/not' does not exist
2020-12-13 17:01:06 -08:00
# 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'
2021-11-19 21:11:28 +01:00
#CHECKERR: warning: Path '/not' does not exist
2020-12-13 17:01:06 -08:00
#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'
2021-11-19 21:11:28 +01:00
#CHECKERR: warning: Path '/not' does not exist
2020-12-13 17:01:06 -08:00
#CHECK: Not hung