09.06.2013 Views

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Programming Commands <strong>XENIX</strong> Programming<br />

csh (continued)<br />

The left sides of substitutions are strings, not regular expressions in the sense of the<br />

editors. Any character can be used in place of slash {/) as the delimiter. A backslash {\)<br />

quotes the delimiter into the 1 and r strings. An & in the right side is replaced by the<br />

text from the left. A \ quotes &. A null l uses the previous string either from an l or<br />

from a contextual scan string s in !?s?. The trailing delimiter in a substitution or the<br />

trailing ? in a contextual scan can be omitted if a newline follows immediately.<br />

A history reference may be given without an event specification, for example, !$. In<br />

this case, the reference is to the previous command unless a previous history reference<br />

occurred on the same line, in which case this form repeats the previous reference. Thus<br />

!?foo?"!$ gives the first and last arguments from the command ma<strong>tc</strong>hing ?foo?.<br />

A special abbreviation of a history reference occurs when the first nonblank character<br />

of an input · line is a caret ('"'). This is equivalent to !:s" and provides a convenient<br />

shorthand for substitutions on the text of the previous line. Thus, "lb"lib fixes the<br />

spelling of lib in the previous command. Finally, a history substitution may be<br />

surrounded with braces ({ }) if necessary to insulate it from the characters that follow.<br />

Thus, after Is -ld-paul we might do !{I}a to do Is -ld-paula, while !la would look for a<br />

command starting Ia.<br />

Quotations with ' and "<br />

The quotation of strings by ' and " can be used to prevent all or some of the remaining<br />

substitutions. Strings enclosed in ' are prevented any further interpretation. Strings<br />

enclosed in " are variable, and command expansion may occur.In both cases, the<br />

resulting text becomes (all or part of) a single word. Only in one special case (see<br />

"Command Substitution" later in this entry) does a " quoted string yield parts of more<br />

than one word; ' quoted strings never do.<br />

Alias Substitution<br />

The shell maintains a list of aliases that can be established, displayed, and modified by<br />

the alias and unalias commands. After a command line is scanned, it is parsed into<br />

distinct commands, and the first word of each command, left-to-right, is checked to see<br />

if it has an alias. If it does, then the text that is the alias for that command is reread<br />

with the history mechanism available as though that command were the previous input<br />

line. The resulting words replace the command and argument list. If no reference is<br />

made to the history list, then the argument list is left unchanged.<br />

Thus if the alias for Is is Is -1 the command "Is /usr" would map to "Is -1 /usr". Similarly,<br />

if the alias for lookup was grep "!" /e<strong>tc</strong>/passwd" then "lookup bill" would map to "grep<br />

bill /e<strong>tc</strong>/passwd". If an alias is found, the word transformation of the input text is<br />

performed, and the aliasing process begins again on the reformed input line. If the first<br />

word of the new text is the same as the old, flagging it will prevent further aliasing and<br />

will preclude looping. Other loops are detected and cause an error. The mechanism<br />

allows aliases to introduce parser metasyntax. Thus, we can alias print as "'pr\!* I lpr"'<br />

to make a command that paginates its arguments to the line printer.<br />

B-38

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!