eexxpprr -- Command

Compute a command-line expression
eexxpprr _a_r_g_u_m_e_n_t ...

The arguments  to eexxpprr form  an expression.  eexxpprr  evaluates the expression
and writes the result on the  standard output.  Among other uses, eexxpprr lets
the user perform arithmetic in shell command files.

Each _a_r_g_u_m_e_n_t  is a separate  token in the  expression.  An argument  has a
logical value `false'  if it is a null string  or has numerical value zero,
`true' otherwise.   Integer arguments consist of  an optional sign followed
by a  string of  decimal digits.   The range of  valid integers is  that of
signed long integers.  No check  is made for overflow or illegal arithmetic
operations.  Floating point numbers are not supported.

The following list  gives each eexxpprr operator and its  meaning.  The list is
in  order  of   increasing  operator  precedence;  operators  of  the  same
precedence  are grouped  together.  All operators  associate left  to right
except the  unary operators `!',  `-', and `lleenn', which  associate right to
left.  The spaces  shown are significant - they separate  the tokens of the
expression.

{ _e_x_p_r_1, _e_x_p_r_2, _e_x_p_r_3 }
     Return  _e_x_p_r_2  if  _e_x_p_r_1  is  logically  true,  and  _e_x_p_r_3  otherwise.
     Alternatively, { _e_x_p_r_1 , _e_x_p_r_2 }  is equivalent to { _e_x_p_r_1 , _e_x_p_r_2 , 00
     }.

_e_x_p_r_1 | _e_x_p_r_2
     Return _e_x_p_r_1 if it is true, _e_x_p_r_2 otherwise.

_e_x_p_r_1 & _e_x_p_r_2
     Return _e_x_p_r_1 if both are true, zero otherwise.

_e_x_p_r_1 _r_e_l_a_t_i_o_n _e_x_p_r_2
     Where _r_e_l_a_t_i_o_n  is one of <,  <=, >, >=, ==, or !=,  return one if the
     _r_e_l_a_t_i_o_n is  true, zero otherwise.  The comparison  is numeric if both
     arguments can be interpreted as numbers, lexicographic otherwise.  The
     lexicographic comparison is the same as ssttrrccmmpp (see ssttrriinngg).

_e_x_p_r_1 + _e_x_p_r_2

_e_x_p_r_1 - _e_x_p_r_2
     Add or  subtract the integer arguments.  The  expression is invalid if
     either _e_x_p_r is not a number.

_e_x_p_r_1 * _e_x_p_r_2

_e_x_p_r_1 / _e_x_p_r_2

_e_x_p_r_1 % _e_x_p_r_2
     Multiply, divide, or  take remainder of the arguments.  The expression
     is invalid if either _e_x_p_r is not numeric.

_e_x_p_r_1 : _e_x_p_r_2
     Match patterns  (regular expressions).   _e_x_p_r_2 specifies a  pattern in
     the  syntax used  by eedd.  It is  compared to _e_x_p_r_1,  which may  be any
     string.  If  the \(...\) pattern occurs in  the regular expression the
     matching operator returns the  matched field from the string; if there
     is more than one \(...\) pattern the extracted fields are concatenated
     in the result.  Otherwise, the matching operator returns the number of
     characters matched.

lleenn _e_x_p_r
     Return the length of _e_x_p_r. It behaves like ssttrrlleenn (see ssttrriinngg). _l_e_n is
     a reserved word in eexxpprr.

!_e_x_p_r
     Perform logical negation: return zero if _e_x_p_r is true, one otherwise.

-_e_x_p_r
     Unary  minus: return  the negative  of its  integer argument.   If the
     argument is non-numeric the expression is invalid.

( _e_x_p_r )
     Return  the _e_x_p_r.  The parentheses allow  grouping expressions  in any
     desired way.

The following operators have special meanings  to the shell sshh, and must be
quoted to be interpreted correctly: { } ( ) < > & | *.

_S_e_e _A_l_s_o
ccoommmmaannddss, eedd, kksshh, sshh, tteesstt

_N_o_t_e_s
eexxpprr returns  zero if the expression  is true, one if false,  and two if an
error occurs.  In the latter case an error message is also printed.
