Skip to content

Commit 7c94c8a

Browse files
qec-pconnermartin-schulze-vireso
authored andcommitted
* Documenting new --returned-status arg.
1 parent a3803a6 commit 7c94c8a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

man/bats.7.ronn

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
204215
Piping of command output is especially helpful when the output needs to be
205216
modified in some way (e.g. the command outputs binary data into stdout, which
206217
cannot be stored as-is in an environment variable).

0 commit comments

Comments
 (0)