From f427c2dca796f8e0f1bf955eaceadcf5f688405b Mon Sep 17 00:00:00 2001 From: John Albietz Date: Mon, 17 Mar 2014 14:29:47 -0700 Subject: [PATCH] added example of piping commands together with run --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index a863264c..62ae7d5f 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,17 @@ an error message. } ``` +You may also find it useful to pipe commands together. To accomplish this with +the `run` helper, you will need to wrap the pipe in `bash -c` command: + +```bash +@test "invoking foo displays 3 lines of output" { + run bash -c "foo | wc -l" + [ "$status" -eq 1 ] + [ "$output" -eq 3 ] +} +``` + The `$status` variable contains the status code of the command, and the `$output` variable contains the combined contents of the command's standard output and standard error streams.