Node:Complex formats, Previous:Formats for general objects, Up:Formatted output



Complex formats

%? Indirection The ? format directive uses up two arguments. It calls format recursively, using the first argument as a format control string, and the second argument (which must be a sequence) as the list of arguments to process.

Q1> printf "%s%?%s" "Before<" "(%d;%#x)" [10 20] ">After."
Before<(10;0x14)>After.

%#? Indirection. Same as %?, except that one one argument is consumed, which is used as a format control string to a recursive call to (s)printf. The recursive call may use arguments from the original call:

Q2> printf "%s%#?%s" "Before<" "[%d;%#x]" 10 20 ">After."
Before<[10;0x14]>After.

%#count{actions%} Iteration Keep repeating the actions, until there are no more arguments. Repeat at most count times (default is infinity).

%count{actions%} Iteration Same as %#count{actions%}, but uses one argument, which must be a sequence. That sequence used whenever arguments are needed by the actions.

Q1> printf "%{(%s)%}" [3 4 5]
(3)(4)(5)
Q2> printf "%#{(%s)%}" 3 4 5
(3)(4)(5)

%^ Break from iteration