Skip to content

Instantly share code, notes, and snippets.

@avdi
Created August 1, 2013 14:23
Show Gist options
  • Select an option

  • Save avdi/6131832 to your computer and use it in GitHub Desktop.

Select an option

Save avdi/6131832 to your computer and use it in GitHub Desktop.
Open3.pipeline_r(
%W[xmllint --xinclude --xmlout #{spine_file}],
# In order to clean up extraneous namespace declarations we need a second
# xmllint process
%W[xmllint --format --nsclean --xmlout -]) do |output, wait_thr|
open(codex_file, 'w') do |f|
IO.copy_stream(output, f)
end
end
@bf4

bf4 commented Aug 1, 2013

Copy link
Copy Markdown

Wait, this does what?

@kennethkalmer

Copy link
Copy Markdown

@rwjblue

rwjblue commented Aug 1, 2013

Copy link
Copy Markdown

So it is basically piping the output from the first command into the input of the second command then passing the output of the last command to the block.

So command_one | command_two > OUTPUT

Right?

@avdi

avdi commented Aug 1, 2013

Copy link
Copy Markdown
Author

Yep. And then IO.copy_stream pipes the output into a file. Yay!

@avdi

avdi commented Aug 1, 2013

Copy link
Copy Markdown
Author

The important thing is that these are real pipes - it's not collecting all the output from the first before it starts executing the second process.

@bf4

bf4 commented Aug 1, 2013

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment