Unix was created with the intent to provide many small single purpose tools that could be combined to achieve the desired result. Each small single purpose tool took an input and produced an output. This output could then be given as input to the next tool. This technique was called piping.
For example to get the results of a operation from the log as it is going you could do this:
tail -f logfile | grep RESULT ;
Which translates the end of the file as it changes and output each line that contains the word RESULT
Unix Pipes are a very powerful tool, but they are limited by the several factors: they are only designed to be binary pipes and they are barely supported by the operating system. Each tool was a stand alone program or script which might be designed to be used in a pipe.
Lets address the first problem. Most users use data to represent many things; e.g. text, images, sound and video. A tool expecting a text file may not graciously handle an image file, which to a text tool, contains control characters.
As such a tool can be defined by the input it expects and the output it produces. In this way the tool system can ensure that only compatible tools are connected, i.e. an image reader is not connected to a text writter.
input/output :=
void
| binary | text | image | sound | video
| record
;
If a tool has no input or output it is declared as void.
Supporting a vocabulary of input/output types has just allowed the shell to determine incorrect couplings and is the beginning of tool support.
The shell never knew the valid arguments for a tool.
The shell never knew the tools result codes and there meaning.
This is an example gramma for a tool chain that takes a text file and converts it to the BeOS/Mac New Line format.
define text2obos ( input void, output void )
- filename source
- filename target
{
load -source $source
| binary2text
| text2binary -obos
| save -target $target
;
}
This defines a tool "text2obos" which takes no input and produces no output. It has two arguments a source and a target filename. It opens the source, loads the binary data, converts it to text, the text to binary (obos encoded) and saves it to the target file.
This could then be used to retrieve files from a web site.
define downloadWebText ( input void, output void )
- uri source
{
web\download -source $source ;
text2obos -source $source -target $target ;
}
This defines a tool "text2obos" which takes no input and produces no output. It has one argument a source URI. It downloads the source. Then it converts it to obos encoded.
KnownTools