Intel XENIX 286 Programmers Guide (86) - Tenox.tc
Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc
XENIX Programming Programming Commands csh (continued) To select words from an event, we can follow the event specification by a colon (:) and a designator for the desired words. The words of an input line are nu mbered from 0, the first (usually command) word being 0, the second word (first argument) being 1, and so on. The basic word designators are 0 First (command) word n nth argument First argument (that is, 1) $ Last argument 96 Word matched by (immediately preceding) ?s? search x-y Range of words -y Abbreviates 0-y * Abbreviates "-$, or nothing if only one word in event x* Abbreviates x-$ x- Like x* but omitting word $ The : separating the event specification from the word designator can be omitted if the argument selector begins with a " , $, *, -, or %. A sequence of modifiers, each preceded by a colon, can be placed after the optional word designator. The following modifiers are defined: h Removes a trailing path name component r Removes a trailing .xx:x component s/l/r/ Substitutes l for r t Removes all leading path name components c5c Repeats the previous substitution g Applies the change globally, prefixing the above p Prints the new command but do not execute it q Quotes the substituted words, preventing substitutions X Like q, but breaks into words at blanks, tabs, and newlines The modification is applied only to the first modifiable word unless preceded by a g. In any case, it is an error for no word to be applicable. B-37
Programming Commands XENIX Programming csh (continued) The left sides of substitutions are strings, not regular expressions in the sense of the editors. Any character can be used in place of slash {/) as the delimiter. A backslash {\) quotes the delimiter into the 1 and r strings. An & in the right side is replaced by the text from the left. A \ quotes &. A null l uses the previous string either from an l or from a contextual scan string s in !?s?. The trailing delimiter in a substitution or the trailing ? in a contextual scan can be omitted if a newline follows immediately. A history reference may be given without an event specification, for example, !$. In this case, the reference is to the previous command unless a previous history reference occurred on the same line, in which case this form repeats the previous reference. Thus !?foo?"!$ gives the first and last arguments from the command matching ?foo?. A special abbreviation of a history reference occurs when the first nonblank character of an input · line is a caret ('"'). This is equivalent to !:s" and provides a convenient shorthand for substitutions on the text of the previous line. Thus, "lb"lib fixes the spelling of lib in the previous command. Finally, a history substitution may be surrounded with braces ({ }) if necessary to insulate it from the characters that follow. Thus, after Is -ld-paul we might do !{I}a to do Is -ld-paula, while !la would look for a command starting Ia. Quotations with ' and " The quotation of strings by ' and " can be used to prevent all or some of the remaining substitutions. Strings enclosed in ' are prevented any further interpretation. Strings enclosed in " are variable, and command expansion may occur.In both cases, the resulting text becomes (all or part of) a single word. Only in one special case (see "Command Substitution" later in this entry) does a " quoted string yield parts of more than one word; ' quoted strings never do. Alias Substitution The shell maintains a list of aliases that can be established, displayed, and modified by the alias and unalias commands. After a command line is scanned, it is parsed into distinct commands, and the first word of each command, left-to-right, is checked to see if it has an alias. If it does, then the text that is the alias for that command is reread with the history mechanism available as though that command were the previous input line. The resulting words replace the command and argument list. If no reference is made to the history list, then the argument list is left unchanged. Thus if the alias for Is is Is -1 the command "Is /usr" would map to "Is -1 /usr". Similarly, if the alias for lookup was grep "!" /etc/passwd" then "lookup bill" would map 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 reformed input line. If the first word of the new text is the same as the old, flagging it will prevent further aliasing and will preclude looping. Other loops are detected and cause an error. The mechanism allows aliases to introduce parser metasyntax. Thus, we can alias print as "'pr\!* I lpr"' to make a command that paginates its arguments to the line printer. B-38
- Page 251 and 252: m4: Macro Processor XENIX Programmi
- Page 253 and 254: C Language Portability XENIX Progra
- Page 255 and 256: C Language Portability XENIX Progra
- Page 257 and 258: C Language Portability XENIX Progra
- Page 259 and 260: C Language Portability XENIX Progra
- Page 261 and 262: C Language Portability XENIX Progra
- Page 263 and 264: C Language Portability XENIX Progra
- Page 266 and 267: APPENDIX B PROG RAMMING COMMANDS Th
- Page 268 and 269: XENIX Programming ad b (continued)
- Page 270 and 271: XENIX Programming Programming Comma
- Page 272 and 273: XENIX Programming Programming Comma
- Page 274 and 275: XENIX Programming Programming Comma
- Page 276 and 277: XENIX Programming Programming Comma
- Page 278 and 279: XENIX Programming Programming Comma
- Page 280 and 281: XENIX Programming Programming Comma
- Page 282 and 283: XENIX Programming Programming Comma
- Page 284 and 285: XENIX Programming as (continued) Fi
- Page 286 and 287: XENIX Programming Programming Comma
- Page 288 and 289: XENIX Programming Programming Comma
- Page 290 and 291: XENIX Programming Programm ing Comm
- Page 292 and 293: XENIX Programming Programming Comma
- Page 294 and 295: XENIX Programming Programming Comma
- Page 296 and 297: XENIX Programming Programm ing Comm
- Page 298 and 299: XENIX Programming Programming Comma
- Page 300 and 301: XENIX Programming Programming Comma
- Page 304 and 305: XENIX Programming Programming Comma
- Page 306 and 307: XENIX Programming Programming Comma
- Page 308 and 309: XENIX Programming Programming Comma
- Page 310 and 311: XENIX Programming Programming Comma
- Page 312 and 313: XENIX Programming Programming Comma
- Page 314 and 315: XENIX Programm ing Programming Comm
- Page 316 and 317: XENIX Programming Programming Comma
- Page 318 and 319: XENIX Programming Programming Comma
- Page 320 and 321: XENIX Programming Programming Comma
- Page 322 and 323: XENIX Programming Programming Comma
- Page 324 and 325: XENIX Programming Programming Comma
- Page 326 and 327: XENIX Programming Programming Comma
- Page 328 and 329: XENIX Programming Programming Comma
- Page 330 and 331: XENIX Programming Programming Comma
- Page 332 and 333: XENIX Programming Programming Comma
- Page 334 and 335: XENIX Programming Programming Comma
- Page 336 and 337: XENIX Programming Programming Comma
- Page 338 and 339: XENIX Programming Programming Comma
- Page 340 and 341: XENIX Programming Programming Comma
- Page 342 and 343: XENIX Programming Programming Comma
- Page 344 and 345: XENIX Programming lex (continued) E
- Page 346 and 347: XENIX Programming Programming Comma
- Page 348 and 349: XENIX Programming Programming Comma
- Page 350 and 351: XENIX Programming Programming Comma
<strong>XENIX</strong> Programming Programming Commands<br />
csh (continued)<br />
To select words from an event, we can follow the event specification by a colon (:) and<br />
a designator for the desired words. The words of an input line are nu mbered from 0, the<br />
first (usually command) word being 0, the second word (first argument) being 1, and so<br />
on. The basic word designators are<br />
0 First (command) word<br />
n nth argument<br />
First argument (that is, 1)<br />
$ Last argument<br />
96 Word ma<strong>tc</strong>hed by (immediately preceding) ?s? search<br />
x-y Range of words<br />
-y Abbreviates 0-y<br />
* Abbreviates "-$, or nothing if only one word in event<br />
x* Abbreviates x-$<br />
x- Like x* but omitting word $<br />
The : separating the event specification from the word designator can be omitted if the<br />
argument selector begins with a " , $, *, -, or %. A sequence of modifiers, each<br />
preceded by a colon, can be placed after the optional word designator. The following<br />
modifiers are defined:<br />
h Removes a trailing path name component<br />
r Removes a trailing .xx:x component<br />
s/l/r/ Substitutes l for r<br />
t Removes all leading path name components<br />
c5c Repeats the previous substitution<br />
g Applies the change globally, prefixing the above<br />
p Prints the new command but do not execute it<br />
q Quotes the substituted words, preventing substitutions<br />
X Like q, but breaks into words at blanks, tabs, and newlines<br />
The modification is applied only to the first modifiable word unless preceded by a g. In<br />
any case, it is an error for no word to be applicable.<br />
B-37