Skip to content

Instantly share code, notes, and snippets.

@irskep
Created December 1, 2011 18:14
Show Gist options
  • Save irskep/1418689 to your computer and use it in GitHub Desktop.
Save irskep/1418689 to your computer and use it in GitHub Desktop.
Pipes3k

Commands defined and referenced by [ID]: "command in quotes"

After definition, commands may be referenced by ID

Connections defined by reference => reference [=> reference ...]

Expressions are separated by ;

  • file1.txt: one
  • file2.txt: two
> "cat file1.txt" => "echo";
one

> A: "cat file1.txt"; B: "echo"; A -> B;
one

> A: "cat file 1.txt" => B: "echo" => C: "echo"; A => C;
one
one

stdout is piped with =>, =out>, or =0>

stderr is piped with =err>, or =1>

Other pipes are probably piped with =#>

Arrow supports most of Python slice syntax, so =0:2> is stdout and stderr, =0:-1> is all but the last output pipe, and =:> is all output pipes.

  • double_out: print out to stdout, print err to stderr
  • merge_pipes: non-deterministically merge all input pipes into one based on time
> "double_out" => "echo";
out

> "double_out" =out> "echo";
out

> "double_out" =err> "echo";
err

> "double_out" =:> "merge_pipes";
out
err

Now imagine that identifiers are persistent as long as the program is still running, so you can have a less-like program running in some window and can dynamically send arbitrary output to it from another terminal.

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