[manual index][section index]


plumbing - plumbing rules


Plumbing rules tell plumber(8) how to route plumbing messages generated by applications using plumbmsg(2).

The file is a set of rules separated by blank lines. Each rule is a set of patterns followed by a set of actions. The rules are interpreted in order. The first rule whose patterns all match is applied, and no further rules are examined. Comments start with # and continue to end of line. Single quotes protect special characters (use '' to get a single quote).

A pattern has the general form:

field verb arg

Each field corresponds to a field in the incoming plumbing message:

Source application
Destination port
Working directory
Format of the data (eg, text or image)
A line of name=value pairs
The message data (an array of bytes)

The verbs are:

Exact string comparison with arg
Regular expression comparison with arg
Arg must name an existing directory
Arg must name an existing file
Set the value of the field to arg. This verb operates in place, so put it after all other patterns in the rule.

The arg can refer to one of the following variables:

$0 to $9
Substrings resulting from the most recent regular expression match: $0 is the entire substring; $1 the first parenthesised substring, etc.
The file name examined by the last isfile verb.
The directory name examined by the last isdir verb.

The following actions are provided:

plumb to port
Route the message to the given plumbing port.
plumb start command arg ...
If no program is currently listening on the current rule's port, start the command with the given arguments. The `$' variables listed above can be used, to include part of the message in the command line arguments to the program. They are replaced in the command string by their actual values.

For example, the following rule sends the names of module files- file names ending with suffix `.m'- to wm-brutus(1), starting it if it is not already running:

kind is text
data matches '([a-zA-Z0-9]+.m)(:[0-9]+)?'
data isfile     /module/$1
data set        /module/$0
plumb to edit
plumb start /dis/wm/brutus.dis $file$2

Note the use of $2 in the start action to pass brutus the line number selected by the second parenthesised expression in the pattern.




plumb(1), plumbmsg(2), plumber(8)

PLUMBING(6 ) Rev:  Thu Feb 15 14:43:48 GMT 2007