Skip to content

Commit

Permalink
* Documenting new --returned-status arg.
Browse files Browse the repository at this point in the history
  • Loading branch information
qec-pconner authored and martin-schulze-vireso committed Jul 13, 2023
1 parent a3803a6 commit 7c94c8a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions man/bats.7.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,17 @@ command of interest.
[ "$output" = "bar output." ]
}

Similarly, --returned-status N (or --returned-status=N) can be used for similar
functionality. This option supports negative values, which always return the
of the command starting from the end and in reverse order.

@test "invoking foo piped to bar always return foo status" {
run bats_pipe --returned-status -2 foo \| bar
# status of bar is ignored, status is always from foo.
[ "$status" -eq 2 ]
[ "$output" = "bar output." ]
}

Piping of command output is especially helpful when the output needs to be
modified in some way (e.g. the command outputs binary data into stdout, which
cannot be stored as-is in an environment variable).
Expand Down

0 comments on commit 7c94c8a

Please sign in to comment.