File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -201,6 +201,17 @@ command of interest.
201201 [ "$output" = "bar output." ]
202202 }
203203
204+ Similarly, --returned-status N (or --returned-status=N) can be used for similar
205+ functionality. This option supports negative values, which always return the
206+ of the command starting from the end and in reverse order.
207+
208+ @test "invoking foo piped to bar always return foo status" {
209+ run bats_pipe --returned-status -2 foo \| bar
210+ # status of bar is ignored, status is always from foo.
211+ [ "$status" -eq 2 ]
212+ [ "$output" = "bar output." ]
213+ }
214+
204215Piping of command output is especially helpful when the output needs to be
205216modified in some way (e.g. the command outputs binary data into stdout, which
206217cannot be stored as-is in an environment variable).
You can’t perform that action at this time.
0 commit comments