Mercurial > hg > toybox
changeset 1629:0459ee56c9d6 draft
Fluff out help text.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 28 Dec 2014 14:38:14 -0600 |
parents | 59a02a1c9f77 |
children | 990776cf60db |
files | toys/pending/expr.c |
diffstat | 1 files changed, 21 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/pending/expr.c Sat Dec 27 13:52:40 2014 -0600 +++ b/toys/pending/expr.c Sun Dec 28 14:38:14 2014 -0600 @@ -13,15 +13,31 @@ bool "expr" default n help - usage: expr args + usage: expr ARG1 OPERATOR ARG2... + + Evaluate expression and print result. For example, "expr 1 + 2". - Evaluate expression and print result. + The supported operators are (grouped from highest to lowest priority): + + ( ) : * / % + - != <= < >= > = & | - The supported operators, in order of increasing precedence, are: + Each constant and operator must be a sparate command line argument. + All operators are infix, meaning they expect a constant (or expression + that resolves to a constant) on each side of the operator. Operators of + the same priority (within each group above) are evaluated left to right. + Parentheses may be used (as separate arguments) elevate the priority + of expressions. - | & = > >= < <= != + - * / % : + Calling expr from a command shell requires a lot of \( or '*' escaping + to avoid interpreting shell control characters. - In addition, parentheses () are supported for grouping. + The & and | operators are logical, not bitwise) and may operate on + strings (a blank string is "false"). Comparison operators may also + operate on strings (alphabetical sort). + + Constants may be strings or integers. Comparison, logical, and regex + operators may operate on strings (a blank string is "false"), other + operators require integers. */ // TODO: int overflow checking