[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The "apply code" selected determines the method of evaluating the expression. There are five apply codes, including the non-use of an apply code.
This is the most common expression type. Expressions of this sort come in three flavors:
The result is the value of value-name, if defined. Otherwise it is the empty string.
The result of the basic expression is the result of the full expression, See section Basic Expression.
If there is a defined value for value-name, then the basic-expr is evaluated. Otherwise, the result is the empty string.
If value-name is defined, use basic-expr as a format string for sprintf. Then, if the basic-expr is either a back-quoted string or a parenthesized expression, then hand the result to the appropriate interpreter for further evaluation. Otherwise, for single and double quote strings, the result is the result of the sprintf operation. Naturally, if value-name is not defined, the result is the empty string.
For example, assume that ‘fumble’ had the string value, ‘stumble’:
[+ % fumble `printf '%%x\\n' $%s` +] |
This would cause the shell to evaluate "‘printf '%x\n' $stumble’". Assuming that the shell variable ‘stumble’ had a numeric value, the expression result would be that number, in hex. Note the need for doubled percent characters and backslashes.
Two basic-expr-s are required. If the value-name is defined, then the first basic-expr-1 is evaluated, otherwise basic-expr-2 is.
Evaluate basic-expr only if value-name is not defined.
This combines the functions of ‘?’ and ‘%’. If value-name is defined, it behaves exactly like ‘%’, above, using basic-expr-1. If not defined, then basic-expr-2 is evaluated.
For example, assume again that ‘fumble’ had the string value, ‘stumble’:
[+ ?% fumble `cat $%s` `pwd` +] |
This would cause the shell to evaluate "‘cat $stumble’". If ‘fumble’ were not defined, then the result would be the name of our current directory.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Bruce Korb on August 21, 2015 using texi2html 1.82.