Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for piping together two or more commands #847

Open
amigalemming opened this issue Jan 5, 2024 · 1 comment
Open

Support for piping together two or more commands #847

amigalemming opened this issue Jan 5, 2024 · 1 comment

Comments

@amigalemming
Copy link

I guess this has been asked for a thousand times, but I cannot find it in the Docs or FAQ.

I want to do this the proper way:

do (Stdout stream) <- cmd "producer"
   cmd_ "consumer" (StdinBS stream)

However, it will not work, because consumer is only started after producer finished. I would need to add fork:

do (Stdout stream) <- fork $ cmd "producer"
   cmd_ "consumer" (StdinBS stream)

But we are in the Action monad, thus no fork available. :-(

If a pipe connection is currently not possible, then please implement it. If it is already possible, please document it. At least, this ticket might be an anchor for other ones looking for a solution.

@simonmichael
Copy link

simonmichael commented Dec 8, 2024

I think this is different what what you're wanting, but for others searching: this works:

  -- run a pipe with a single cmd invocation
  newitems <- fromStdout <$> (cmd Shell "set -o pipefail; foo | bar" :: Action (Stdout String))

The shell pipefail setting is needed, otherwise errors in foo would not stop the shake action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants