|
|
Blog
Plumb, the pipe shell
plumb by Tibor 'Igor2' Palinkas on 2020-02-13 | Tags: tool, draw |
Abstract: n/a
Datasheet
Project | plumb |
---|---|
Scope | pipe shell (graphs of piped processes) |
Status | works; finished (still maintained) |
License | GPL2+ |
Web | http://www.repo.hu/projects/plumb |
VCS | svn://svn.repo.hu/plumb/trunk |
UNIX background
Plumb has the same UNIX motivation that is mentioned in the blog post for animator .
Plumb
Most of our tools were written as multiple smaller programs or scripts piped together. Piping in a UNIX shell is simple: program1 | program2 | program3. However, this syntax works only for a simple, linear, stdout-to-stdin piping. There are a few cases we commonly needed and can not be easily done in shell:
- Building loops. The "69" setup: prog1 | prog2, then prog2's stdout piped back to prog1 stdin, forming a loop; this is a must for driving animator or projector in interactive mode: prog1 is the driver that writes drawing commands but also wants to read key/mouse events
- Splitting streams. Unix offers tee(1) for basic splitting, but it can write only a file. It is not easy to get the shell do something like prog1 | prog2 and feed the same stdout of prog 1 into prog3.
- Merging streams. The other way around, both prog1 and prog2 producing output to the same prog3. Their streams need to be merged. The real hard part is handling when prog3 is blocking on stdin or when prog1 or prog2 generates an EOF while the other source is still emitting data.
Mate Nagy started to write the first version of plumb a month after he started to work on animator. The first version already solved most of the above three problems, but it had major problems with eof handling.
During the summer break from challenge24, Mate rolled a new version with different syntax, which later became plumb 2.0. This one had better handling of eof and blocking but still had problems with plumb's own stdio and buffering.
Two years later I introduced a new syntax which removed side effects from pipes and introduced virtual processes. This made the whole design much simpler and more flexible. This syntax became the current version, plumb3. Plumb3 also has explicit and unified eof, blocking and fd handling and a concept of atomic datagrams. Plumb's stdio works the same way as any other source or sink in plumb3.