Expressions
Arithmetic, boolean, and bit operations
- can use standard C binary operators for equality (= =, !=) (equals, not equal)
- note the difference between equality (= =) and assignment (=)
- arithmetic (+, -, *, /, %) (plus, minus, times, divide, remainder)
- boolean (||, & & ) (or, and)
- bit operations (|, & , ^, > > , < < ) (bit-or, bit-and, bit-xor, shift-right, shift-left)
- syntax of > > and < < is "< int> op < var> "
- unary operators
- arithmetic (-, ++, --) (negate, increment, decrement)
- boolean (!) (not)
- bit (> > , < < ) (syntactic sugar for "1 > > < var> ", "1 < < < var> "
String Expressions
Strings use only equality (and inequality) operators, but allow for
< string> [ == | != ] < string>
- tests for literal equality
< string> [ ~= | !~ ] < pattern>
- tests for equality, matching wildcards in < pattern>
File-test predicates
- Are of the form -< flag> < filename> and are all boolean tests. (see page 208)
Assignment operators
- In addition, we have the assignment operators
= evaluate RHS and store in LHS
+= evaluate RHS and add to current LHS
-= evaluate RHS and subtract from current LHS
*= evaluate RHS and multiply to current LHS
/= evaluate RHS and use to divide current LHS
Assignment
- Where the RHS is a constant or a variable expression, it can be assigned to a variable by "set" or "setenv",
depending on the type of variable. "set" can also be used to assign a simple RHS to an element of a list.
- Extending a list requires a form like
set < var> = ( $< var> new_entries )
- where new_entries can be constants or variables, or a mix, and can include lists.
- Lists are flat; that is, cannot contain lists as elements. if you put a list in a list, the lists are instead appended.
- If the RHS is an expression, we have to use the syntax
@ < var> < op> < expr>
- where < op> is one of the assignment operators above.
- Note that assignment operators have precedence like that of equality operators, so if you use any of ( ==, !=,
& , ^, |, & & , || ) in < expr> , you will have to place the expression in parens for correct
evaluation.