Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   expr.1p    ( 1 )

оценивать аргументы как выражение (evaluate arguments as an expression)

Расширенное описание (Extended description)

The formation of the expression to be evaluated is shown in the following table. The symbols expr, expr1, and expr2 represent expressions formed from integer and string symbols and the expression operator symbols (all separate arguments) by recursive application of the constructs described in the table. The expressions are listed in order of decreasing precedence, with equal-precedence operators grouped between horizontal lines. All of the operators shall be left-associative.

┌───────────────┬──────────────────────────────────────────┐ │ Expression Description │ ├───────────────┼──────────────────────────────────────────┤ │integer │ An argument consisting only of an │ │ │ (optional) unary minus followed by │ │ │ digits. │ │string │ A string argument; see below. │ ├───────────────┼──────────────────────────────────────────┤ │( expr ) │ Grouping symbols. Any expression can be │ │ │ placed within parentheses. Parentheses │ │ │ can be nested to a depth of │ │ │ {EXPR_NEST_MAX}. │ ├───────────────┼──────────────────────────────────────────┤ │expr1 : expr2 │ Matching expression; see below. │ ├───────────────┼──────────────────────────────────────────┤ │expr1 * expr2 │ Multiplication of decimal integer-valued │ │ │ arguments. │ │expr1 / expr2 │ Integer division of decimal integer- │ │ │ valued arguments, producing an integer │ │ │ result. │ │expr1 % expr2 │ Remainder of integer division of decimal │ │ │ integer-valued arguments. │ ├───────────────┼──────────────────────────────────────────┤ │expr1 + expr2 │ Addition of decimal integer-valued │ │ │ arguments. │ │expr1 - expr2 │ Subtraction of decimal integer-valued │ │ │ arguments. │ ├───────────────┼──────────────────────────────────────────┤ │ │ Returns the result of a decimal integer │ │ │ comparison if both arguments are │ │ │ integers; otherwise, returns the result │ │ │ of a string comparison using the locale- │ │ │ specific collation sequence. The result │ │ │ of each comparison is 1 if the specified │ │ │ relationship is true, or 0 if the │ │ │ relationship is false. │ │expr1 = expr2 │ Equal. │ │expr1 > expr2 │ Greater than. │ │expr1 >= expr2 │ Greater than or equal. │ │expr1 < expr2 │ Less than. │ │expr1 <= expr2 │ Less than or equal. │ │expr1 != expr2 │ Not equal. │ ├───────────────┼──────────────────────────────────────────┤ │expr1 & expr2 │ Returns the evaluation of expr1 if │ │ │ neither expression evaluates to null or │ │ │ zero; otherwise, returns zero. │ ├───────────────┼──────────────────────────────────────────┤ │expr1 | expr2 │ Returns the evaluation of expr1 if it is │ │ │ neither null nor zero; otherwise, │ │ │ returns the evaluation of expr2 if it is │ │ │ not null; otherwise, zero. │ └───────────────┴──────────────────────────────────────────┘ Matching Expression The ':' matching operator shall compare the string resulting from the evaluation of expr1 with the regular expression pattern resulting from the evaluation of expr2. Regular expression syntax shall be that defined in the Base Definitions volume of POSIX.1‐2017, Section 9.3, Basic Regular Expressions, except that all patterns are anchored to the beginning of the string (that is, only sequences starting at the first character of a string are matched by the regular expression) and, therefore, it is unspecified whether '^' is a special character in that context. Usually, the matching operator shall return a string representing the number of characters matched ('0' on failure). Alternatively, if the pattern contains at least one regular expression subexpression "[\(...\)]", the string matched by the back- reference expression "\1" shall be returned. If the back- reference expression "\1" does not match, then the null string shall be returned.

Identification as Integer or String An argument or the value of a subexpression that consists only of an optional unary minus followed by digits is a candidate for treatment as an integer if it is used as the left argument to the | operator or as either argument to any of the following operators: & = > >= < <= != + - * / %. Otherwise, the argument or subexpression value shall be treated as a string.

The use of string arguments length, substr, index, or match produces unspecified results.