eval (1) --- evaluate arithmetic expressions 03/20/80 _U_s_a_g_e eval { } _D_e_s_c_r_i_p_t_i_o_n 'Eval' is used to evaluate arithmetic expressions involving 32-bit integers and shell variables. The expression to be evaluated is given in the arguments, and may be spread out over as many arguments as desired. The value of the expres- sion is printed on standard output one. 'Eval' supports the following operators: + addition - subtraction and unary minus * multiplication / division % modulus << logical left shift >> logical right shift ** exponentiation < less than (returns 1 or 0) > greater than = equal to <= less than or equal to >= greater than or equal to ~= not equal to & bitwise logical and | bitwise logical or ~ bitwise logical complement Operator priority, from highest to lowest, is as follows: - (unary minus) ** * / % << >> + - < <= = ~= >= > ~ & | Parentheses may be freely used to specify the desired order of evaluation. Shell variables may appear in expressions; their values will be substituted when necessary. As always, shell function calls may be included as part of the command line, and will be processed before 'eval' sees the expression. Care should be taken in using characters recognized by the shell as meta-characters (e.g. parentheses, vertical bar, greater than sign). For this reason, it is probably wise to enclose the expression in quotes. eval (1) - 1 - eval (1) eval (1) --- evaluate arithmetic expressions 03/20/80 _E_x_a_m_p_l_e_s eval 10 - 14 + 37**2 set i = [eval i + 1] cat file_stack[eval sp-1] _M_e_s_s_a_g_e_s "Bad element in expression" for missing or unrecognizable expression element. ": domain error" for reference to non-numeric shell variable. ": value error" for reference to undefined shell variable. _S_e_e _A_l_s_o cmp (1), declare (1), forget (1), set (1), hp (1) eval (1) - 2 - eval (1)