| 1 |
expr-about = Print the value of EXPRESSION to standard output |
| 2 |
expr-usage = expr [EXPRESSION] |
| 3 |
expr [OPTIONS] |
| 4 |
expr-after-help = A blank line below separates increasing precedence groups. |
| 5 |
|
| 6 |
EXPRESSION may be: |
| 7 |
|
| 8 |
ARG1 | ARG2 |
| 9 |
ARG1 if it is neither null nor 0, otherwise ARG2 |
| 10 |
|
| 11 |
ARG1 & ARG2 |
| 12 |
ARG1 if neither argument is null or 0, otherwise 0 |
| 13 |
|
| 14 |
ARG1 < ARG2 |
| 15 |
ARG1 is less than ARG2 |
| 16 |
|
| 17 |
ARG1 <= ARG2 |
| 18 |
ARG1 is less than or equal to ARG2 |
| 19 |
|
| 20 |
ARG1 = ARG2 |
| 21 |
ARG1 is equal to ARG2 |
| 22 |
|
| 23 |
ARG1 != ARG2 |
| 24 |
ARG1 is unequal to ARG2 |
| 25 |
|
| 26 |
ARG1 >= ARG2 |
| 27 |
ARG1 is greater than or equal to ARG2 |
| 28 |
|
| 29 |
ARG1 > ARG2 |
| 30 |
ARG1 is greater than ARG2 |
| 31 |
|
| 32 |
ARG1 + ARG2 |
| 33 |
arithmetic sum of ARG1 and ARG2 |
| 34 |
|
| 35 |
ARG1 - ARG2 |
| 36 |
arithmetic difference of ARG1 and ARG2 |
| 37 |
|
| 38 |
ARG1 * ARG2 |
| 39 |
arithmetic product of ARG1 and ARG2 |
| 40 |
|
| 41 |
ARG1 / ARG2 |
| 42 |
arithmetic quotient of ARG1 divided by ARG2 |
| 43 |
|
| 44 |
ARG1 % ARG2 |
| 45 |
arithmetic remainder of ARG1 divided by ARG2 |
| 46 |
|
| 47 |
STRING : REGEXP |
| 48 |
anchored pattern match of REGEXP in STRING |
| 49 |
|
| 50 |
match STRING REGEXP |
| 51 |
same as STRING : REGEXP |
| 52 |
|
| 53 |
substr STRING POS LENGTH |
| 54 |
substring of STRING, POS counted from 1 |
| 55 |
|
| 56 |
index STRING CHARS |
| 57 |
index in STRING where any CHARS is found, or 0 |
| 58 |
|
| 59 |
length STRING |
| 60 |
length of STRING |
| 61 |
|
| 62 |
+ TOKEN |
| 63 |
interpret TOKEN as a string, even if it is a keyword like match or an operator like / |
| 64 |
|
| 65 |
( EXPRESSION ) |
| 66 |
value of EXPRESSION |
| 67 |
|
| 68 |
Beware that many operators need to be escaped or quoted for shells. |
| 69 |
Comparisons are arithmetic if both ARGs are numbers, else lexicographical. |
| 70 |
Pattern matches return the string matched between \( and \) or null; if |
| 71 |
\( and \) are not used, they return the number of characters matched or 0. |
| 72 |
|
| 73 |
Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION |
| 74 |
is null or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an |
| 75 |
error occurred. |
| 76 |
|
| 77 |
Environment variables: |
| 78 |
|
| 79 |
- EXPR_DEBUG_TOKENS=1: dump expression's tokens |
| 80 |
- EXPR_DEBUG_RPN=1: dump expression represented in reverse polish notation |
| 81 |
- EXPR_DEBUG_SYA_STEP=1: dump each parser step |
| 82 |
- EXPR_DEBUG_AST=1: dump expression represented abstract syntax tree |
| 83 |
|
| 84 |
Errors are reported with the expression echoed back and a caret under the |
| 85 |
offending argument whenever stderr is a terminal; anything else reading |
| 86 |
stderr gets the usual single-line message. |
| 87 |
|
| 88 |
# Help messages |
| 89 |
expr-help-version = output version information and exit |
| 90 |
expr-help-help = display this help and exit |
| 91 |
|
| 92 |
# Error messages |
| 93 |
expr-error-unexpected-argument = syntax error: unexpected argument { $arg } |
| 94 |
expr-error-missing-argument = syntax error: missing argument after { $arg } |
| 95 |
expr-error-non-integer-argument = non-integer argument |
| 96 |
expr-error-missing-operand = missing operand |
| 97 |
expr-error-division-by-zero = division by zero |
| 98 |
expr-error-invalid-regex-expression = Invalid regex expression |
| 99 |
expr-error-expected-closing-brace-after = syntax error: expecting ')' after { $arg } |
| 100 |
expr-error-expected-closing-brace-instead-of = syntax error: expecting ')' instead of { $arg } |
| 101 |
expr-error-unmatched-opening-parenthesis = Unmatched ( or \( |
| 102 |
expr-error-unmatched-closing-parenthesis = Unmatched ) or \) |
| 103 |
expr-error-unmatched-opening-brace = Unmatched {"\\{"} |
| 104 |
expr-error-invalid-bracket-content = Invalid content of {"\\{\\}"} |
| 105 |
expr-error-trailing-backslash = Trailing backslash |
| 106 |
expr-error-too-big-range-quantifier-index = Regular expression too big |
| 107 |
expr-error-match-utf8 = match does not support invalid UTF-8 encoding in { $arg } |
| 108 |
|
| 109 |
# Diagnostic labels, used when errors are rendered with a source snippet |
| 110 |
expr-diag-help-missing-argument = every operator needs a value on both sides |
| 111 |
expr-diag-help-unexpected-argument = the shell may have expanded an operator; quote it as '{"*"}' or escape it as {"\\*"} |
| 112 |
expr-diag-help-non-integer-argument = arithmetic operators need integers; use = or {"!"}= to compare strings instead |