Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)
User Commands (s) sh(1)
Quoting
The following characters have a special meaning to the shell and cause termination of a word
unless quoted:
; & ( ) | ˆ < > <newline> <space> <tab>
Each of the metacharacters previously listed has a special meaning to the shell and causes termi-
nation of a word unless quoted. A character can be quoted (that is, made to stand for itself) by
preceding it with a \ (backslash). The pair \newline is ignored. All characters enclosed between
a pair of ‘’ (single quotes) are quoted. A single quote cannot appear within single quotes.
Inside "" (double quotes) parameter and command substitution occurs and \ quotes the charac-
ters \, ‘, ’, and $. The meaning of $* and $@@@@ is identical when not quoted or when used as
a parameter assignment value or as a filename. However, when used as a command argument,
’$*’ is equivalent to ’$1d$2d...’, where d is the first character of the IFS parameter, whereas
’$@@@@’ is equivalent to ’$1’ ’$2’ . . . Inside ‘‘ (grave accents) \ (backslash) quotes the char-
acters \, ‘, and $. If the grave accents occur within double quotes, then \ also quotes the ’ (single
quote) character.
The special meaning of reserved words or aliases can be removed by quoting any character of the
reserved word. The recognition of function names or special command names listed later cannot
be altered by quoting them.
Arithmetic Evaluation
An ability to perform integer arithmetic is provided with the let special command. Evaluations
are performed using long arithmetic. Constants are of the form [base#]n, where base is a decimal
number between 2 and 36 representing the arithmetic base and n is a number in that base. If base
is omitted, then base 10 is used.
An arithmetic expression uses the same syntax, precedence, and associativity of expression of
the C language. All the integral operators, other than ++, --, ?:, and , are supported. Named
parameters can be referenced by name within an arithmetic expression without using the parame-
ter substitution syntax. When a named parameter is referenced, its value is evaluated as an arith-
metic expression.
An internal integer representation of a named parameter can be specified with the -i option of the
typeset
special command. Arithmetic evaluation is performed on the value of each assignment
to
a named parameter with the -i attribute. If you do not specify an arithmetic base, the first
assignment to the parameter determines the arithmetic base. This base is used when parameter
substitution occurs.
Because many of the arithmetic operators require quoting, an alternative form of the let com-
mand is provided. For any command that begins with a ((, all the characters until a matching ))
are treated as a quoted expression. More precisely, ((...)) is equivalent to let "...".
Note that ((...)) is a command with a return value, whereas $((...)) is the way to put the string
representation of the value of an arithmetic expression into the command line (that is, it is like a
$ variable).
Prompting
When used interactively, the shell prompts with the value of PS1 before reading a command. If
at any time a newline character is typed and further input is needed to complete a command, then
the secondary prompt (that is, the value of PS2) is issued.
Conditional Expressions
A conditional expression is used with the [[ compound command to test attributes of files and to
compare strings. Word splitting and filename generation are not performed on the words
between [[ and ]]. Each expression can be constructed from one or more of the following unary
or binary expressions:
527188-021 Hewlett-Packard Company 8−31