c

csh(1)

csh(1)

ls -ld Äpaul

one could execute !{l}a to do

ls -ld Äpaula

while !la would look for a command starting with la.

Quoting with Single and Double Quotes

The quotation of strings by single quotes (') and double quotes ( " ) can be used to prevent all or some of the remaining substitutions. Strings enclosed in single quotes are protected from any further interpretation. Strings enclosed in double quotes are still variable- and command-expanded as described below.

In both cases the resulting text becomes (all or part of) a single word. Only in one special case (see Command Substitution below) does a double-quoted string yield parts of more than one word; single-quoted strings never do.

Alias Substitution

csh maintains a list of aliases that can be established, displayed, and modi®ed by the alias and unalias commands. After a command line is scanned, it is parsed into distinct commands and the ®rst word of each command, left-to-right, is checked to see if it has an alias. If it does, the text which is the alias for that command is reread with the history mechanism available as if that command was the previous input line. The resulting words replace the command and argument list. If no reference is made to the history list, the argument list is left unchanged.

Thus, if the alias for ls is ls -l, the command ls /usr maps to ls -l /usr, leaving the argument list undisturbed. Similarly, if the alias for lookup was grep !Ã /etc/passwd , lookup bill maps to grep bill /etc/passwd .

If an alias is found, the word transformation of the input text is performed and the aliasing process begins again on the re-formed input line. Looping is prevented if the ®rst word of the new text is the same as the old by ¯agging it to prevent further aliasing. Other loops are detected and cause an error.

Note that the mechanism allows aliases to introduce parser metasyntax. Thus:

alias print 'pr \!* lp'

makes a command that uses pr(1) to print its arguments on the line printer.

Expressions

Some of the built-in commands take expressions in which the operators are similar to those of C, with the same precedence. These expressions appear in the @, exit, if, and while commands. The following operators are available (shown in order of increasing precedence):

&& Ã & == != =Ä !Ä <= >= < > << >> + - * / % ! Ä ( )

The following list shows the grouping of these operators. The precedence decreases from top to bottom in the list:

*/ % + - << >>

<= >= < > == != =Ä !Ä

The operators ==, !=, , and compare their arguments as strings; all others operate on numbers. The operators and are similar to != and ==, except that the right-hand side is a pattern (contain- ing *s, ?s, and instances of [...] ) against which the left hand operand is matched. This reduces the need for use of the switch statement in shell scripts when all that is really needed is pattern matching.

Strings beginning with 0 are considered octal numbers. Null or missing arguments are considered 0. The result of all expressions are strings that represent decimal numbers. It is important to note that no two components of an expression can appear in the same word. These components should be surrounded by spaces except when adjacent to components of expressions that are syntactically signi®cant to the parser: -, &, , <, >, (, and ).

Also available in expressions as primitive operands are command executions enclosed in curly braces ( { } ) and ®le enquiries of the form -l ®lename, where l is one of:

Section 1138

− 10 −

HP-UX Release 11i: December 2000