Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

added example of piping commands together with run #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

inthecloud247
Copy link

No description provided.

@rianwouters
Copy link

+1

@RomanSaveljev
Copy link

I had to tackle the same issue and I have resorted to the following:

run wc -l <(foo)

In my opinion, this way you have less problems with quoting

@rianwouters
Copy link

In this particular case yes. But in general good to document how to run with pipes.

Verstuurd door Outlook voor Android

On Sat, Oct 10, 2015 at 2:35 AM -0700, "Roman Savelyev" [email protected] wrote:
I had to tackle the same issue and I have resorted to the following:

run wc -l <(foo)

In my opinion, this way you have less problems with quoting


Reply to this email directly or view it on GitHub:
#47 (comment)

@jch
Copy link

jch commented Dec 21, 2015

Thanks for opening this PR. It was helpful

@rianwouters
Copy link

you're welcome :-)
also see https://github.com/rianwouters/bexpect :-)

groetjes,

Rian

Date: Sun, 20 Dec 2015 21:05:05 -0800
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [bats] added example of piping commands together with run (#47)

Thanks for opening this PR. It was helpful


Reply to this email directly or view it on GitHub.

@jch
Copy link

jch commented Dec 21, 2015

After reading through the original issue (#10 (comment)), I decided to avoid using run altogether. It just sets the special variables $output and $status, both of which are easily available. Here's an example: https://github.com/jch/jsg/blob/a960847b03c9de392f30b112d2c7ab2591608a6e/test/bin/jsg_markdown_test.sh#L4-L5

Copy link

@AlexSkrypnyk AlexSkrypnyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As others pointed out, using bash -c is better (covers more cases) than using output redirect.

This approach was tested and it works.

Can we please merge this as using pipes in scripting (especially with grep) is a common approach, therefore this will be useful to many people (I myself just spent 2 hours debugging why run does not support pipes).

yarikoptic pushed a commit to neurodebian/bats that referenced this pull request Sep 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants