Prev: Next: Up: poundctl template[Contents][Index]


10.5.2 Pipelines

A pipeline is a series of one or more commands delimited by pipe sign (‘|’). Each command is either an argument or a function call, in form:

func arg1 arg2...

where func is the name of one of the built-in functions discussed below.

Pipelines are executed from left to right, with the result of the previous command implicitly added to the list of arguments of each subsequent command. For example, the pipeline

.attr | eq $x

is equivalent to

eq $x .attr

i.e. it calls the built-in function eq with two arguments: the value of the variable ‘x’ and attribute ‘attr’ of the cursor value.

The following built-in functions are defined:

Template built-in: and A1 A2

Evaluates to true if pipelines A1 and A2 both evaluate to true. Notice, that there is no boolean shortcut evaluation: both pipelines are evaluated prior to calling and.

Template built-in: or A1 A2

Evaluates to true if at least one of the pipelines A1 and A2 evaluates to true. Notice, that there is no boolean shortcut evaluation: both pipelines are evaluated prior to calling or.

Template built-in: index A1 A2...

Returns the result of indexing its first argument by the following arguments. Thus, if ‘.’ is an array, then:

index . 5

evaluates to its fifth element (‘.[5]’).

Template built-in: len A1

Returns the integer length of its argument.

Template built-in: not A1

Returns true if its argument evaluates to false.

Template built-in: eq A1 A2

Returns true if both its arguments are equal. This applies only if both A1 and A2 are numeric or if they both are strings.

Template built-in: ne A1 A2

Returns true if its arguments (both must be numeric or strings) are not equal.

Template built-in: lt A1 A2

Returns true if A1 is numerically less than A2.

Template built-in: le A1 A2

Returns true if A1 is numerically less than or equal to A2.

Template built-in: gt A1 A2

Returns true if A1 is numerically greater than A2.

Template built-in: ge A1 A2

Returns true if A1 is numerically greater than or equal to A2.

Template built-in: even A1

Returns true if A1, which must evaluate to an integer value, is divisible by 2.

Template built-in: printf FMT A1...

Implements the printf function. FMT must evaluate to string. Rest of arguments is interpreted according to the conversion specifications in FMT. The result is a formatted string.

In addition to the standard conversion specifications, the ‘%v’ specifier is implemented: it formats its argument in the best way, depending on its actual type.

Template built-in: typeof A1

Evaluates to the type of its argument, one of: null, bool, number, integer, string, array, and object.

Template built-in: exists A1 A2

A1 must evaluate to an object and A2 to string. The function evaluates to true if the attribute A2 is present in A1.

Template built-in: add A1 A2...

Returns the sum of its arguments.

Template built-in: sub A1 A2

Returns the difference A1 - A2.

Template built-in: mul A1 A2

Multiplies A1 by A2.

Template built-in: div A1 A2

Divides A1 by A2.


Prev: Next: Up: poundctl template[Contents][Index]