home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume24 / zsh2.1 / part02 < prev    next >
Text File  |  1991-10-24  |  50KB  |  1,859 lines

  1. Newsgroups: comp.sources.misc
  2. From: pfalstad@phoenix.Princeton.EDU (Paul Falstad)
  3. Subject:  v24i002:  zsh2.1 - The Z shell, Part02/19
  4. Message-ID: <1991Oct24.190713.25444@sparky.imd.sterling.com>
  5. X-Md4-Signature: b7e23335657d4b3812c6eef00f32b163
  6. Date: Thu, 24 Oct 1991 19:07:13 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: pfalstad@phoenix.Princeton.EDU (Paul Falstad)
  10. Posting-number: Volume 24, Issue 2
  11. Archive-name: zsh2.1/part02
  12. Environment: BSD
  13. Supersedes: zsh2.00: Volume 18, Issue 84-98
  14.  
  15. #!/bin/sh
  16. # this is zshar.02 (part 2 of zsh2.1.0)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file zsh2.1/man/man1/zsh.1 continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 2; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test ! -f _shar_wnt_.tmp; then
  33.     echo 'x - still skipping zsh2.1/man/man1/zsh.1'
  34. else
  35. echo 'x - continuing file zsh2.1/man/man1/zsh.1'
  36. sed 's/^X//' << 'SHAR_EOF' >> 'zsh2.1/man/man1/zsh.1' &&
  37. Xunless quoted or removed using the \fBunalias\fP builtin:
  38. X.RS
  39. X.PP
  40. X\fBdo done esac then elif else fi for case
  41. Xif while function repeat time until exec command
  42. Xselect coproc noglob \- nocorrect foreach end\fP
  43. X.RE
  44. X.SH COMMENTS
  45. XIn noninteractive shells, or in interactive shells with the
  46. X\fBINTERACTIVE_COMMENTS\fP option set, a word beginning
  47. Xwith the third character of the \fBHISTCHARS\fP parameter
  48. X(`#' by default) causes that word and all the following
  49. Xcharacters up to a newline to be ignored.
  50. X.SH ALIASING
  51. XEvery token in the shell input is checked to see if there
  52. Xis an alias defined for it.
  53. XIf so, it is replaced by the text of the alias if it is in command
  54. Xposition (if it could be the first word of a simple command),
  55. Xor if the alias is global.
  56. XIf the text ends with a space, the next word in the shell input
  57. Xis treated as though it were in command position for purposes of alias
  58. Xexpansion.
  59. XAn alias is defined using the \fBalias\fP builtin; global aliases
  60. Xmay be defined using the \-\fBg\fP option to that bulitin.
  61. X.PP
  62. XAlias substitution is done on the shell input before any
  63. Xother substitution except history substitution.  Therefore,
  64. Xif an alias is defined for the word \fBfoo\fP, alias substitution
  65. Xmay be avoided by quoting part of the word, e.g. \fB\efoo\fP.
  66. XBut there is nothing to prevent an alias being defined
  67. Xfor \fB\efoo\fP as well.
  68. X.SH QUOTING
  69. XA character may be \fIquoted\fP (that is, made
  70. Xto stand for itself) by preceding it with a \e\|.
  71. X\e followed by a newline is ignored.
  72. XAll characters enclosed between a pair of single quotes ('')
  73. Xare quoted.
  74. XA single quote cannot appear within single quotes.
  75. XInside double quotes (""), parameter and command substitution
  76. Xoccurs, and \e quotes the characters \e\|, `, ", and $.
  77. X.SH EXPANSION
  78. XExpansion is performed on the command line after it has been
  79. Xparsed.  The types of expansions performed are
  80. X\fIfilename expansion\fP, 
  81. X\fIprocess substitution\fP,
  82. X\fIparameter expansion\fP,
  83. X\fIcommand substitution\fP,
  84. X\fIarithmetic expansion\fP,
  85. X\fIbrace expansion\fP,
  86. Xand \fIfilename generation\fP.
  87. X.SS Filename Expansion
  88. XEach word is checked to see if it begins with an unquoted ~.
  89. XIf it does, then the word up to a / is checked to see if it matches
  90. Xthe name of a named directory.  If so, then the ~ and the matched portion
  91. Xare replaced with the value of the named directory.
  92. XA ~ by itself or followed by a / is replaced by the value of the
  93. X\fBHOME\fP parameter.
  94. XA ~ followed by a + or a \- is replaced by the value of 
  95. X\fBPWD\fP or \fBOLDPWD\fP, respectively.
  96. X.PP
  97. XNamed directories are typically login directories for users on the system.
  98. XThey may also be defined if the text after the ~ is the name
  99. Xof a shell parameter whose value begins with a /.
  100. XIn certain circumstances (in prompts, for instance), when the shell
  101. Xprints a path, the path is checked to see if it has a named
  102. Xdirectory as its prefix.  If so, then the prefix portion
  103. Xis replaced with a ~ followed by the name of the directory.
  104. XThe longest match is preferred.
  105. X.PP
  106. XIf a word begins with an unquoted \fB=\fP and the
  107. X\fBNO_EQUALS\fP option is not set,
  108. Xthe remainder of the word is taken as the
  109. Xname of a command or alias.  If a command
  110. Xexists by that name, the word is replaced
  111. Xby the full pathname of the command.
  112. XIf an alias exists by that name, the word
  113. Xis replaced with the text of the alias.
  114. XOtherwise the word is checked up to a /
  115. Xto see if it is a number or a \-.  If so,
  116. Xthe matched portion is replaced with
  117. Xthe \fIn\fPth directory in the directory stack,
  118. Xwhere \fIn\fP is the number matched, or
  119. Xthe last directory in the directory stack
  120. Xif a \- is matched.
  121. X.SS Process Substitution
  122. XEach command argument of the form
  123. X\fB<(\fIlist\^\fB)\fR
  124. Xor
  125. X\fB>(\fIlist\^\fB)\fR
  126. Xor
  127. X\fB=(\fIlist\^\fB)\fR
  128. Xis subject to process substitution.
  129. XIn the case of the
  130. X.B <
  131. Xor
  132. X.B >
  133. Xforms, the shell will run process
  134. X.I list
  135. Xasynchronously connected to a named pipe (FIFO).
  136. XThe name of this pipe will become the argument to the command.
  137. XIf the form with
  138. X.B >
  139. Xis selected then writing on this file will provide input for
  140. X.IR list .
  141. XIf
  142. X.B <
  143. Xis used,
  144. Xthen the file passed as an argument will
  145. Xbe a named pipe connected to the output of the
  146. X.I list
  147. Xprocess.
  148. XFor example,
  149. X.RS
  150. X.PP
  151. X\fBpaste <(cut \-f1\fP \fIfile1\fB) <(cut \-f3\fP \fIfile2\fB) | tee >(\fIprocess1\fB) >(\fIprocess2\fB)\fR >/dev/null
  152. X.RE
  153. X.PP
  154. X.BR cut s
  155. Xfields 1 and 3 from
  156. Xthe files
  157. X.I file1
  158. Xand
  159. X.I file2
  160. Xrespectively,
  161. X.BR paste s
  162. Xthe results together, and sends it to the processes
  163. X.I process1
  164. Xand
  165. X.IR process2 .
  166. XNote that the file, which is passed as an argument to the command,
  167. Xis a system
  168. Xpipe 
  169. Xso programs that expect to
  170. X.BR lseek (2)
  171. Xon the file will not work.
  172. XAlso note that the previous example can be more compactly and
  173. Xefficiently written as:
  174. X.RS
  175. X.PP
  176. X\fBpaste <(cut \-f1\fP \fIfile1\fB) <(cut \-f3\fP \fIfile2\fB) > >(\fIprocess1\fB) > >(\fIprocess2\fB)\fR
  177. X.RE
  178. X.PP
  179. Xthe shell uses pipes instead of a FIFOs to implement the latter
  180. Xtwo process substitutions in the above example.
  181. X.PP
  182. XIf
  183. X.B =
  184. Xis used,
  185. Xthen the file passed as an argument will be the name
  186. Xof a temporary file containing
  187. Xthe output of the
  188. X.I list
  189. Xprocess.  This may be used instead of the
  190. X.B <
  191. Xform for a program that expects to \fBlseek\fP(2) on the input file.
  192. X.SS Parameter Expansion
  193. XThe character \fB$\fP is used to introduce parameter expansions.
  194. XSee \fBPARAMETERS\fP below for a description of parameters.
  195. X.PD
  196. X.RS
  197. X.TP
  198. X\fB${\fIname\fB}\fR
  199. XThe value, if any, of the parameter \fIname\fP is substituted.
  200. XThe braces are required with \fIname\fP is followed by
  201. Xa letter, digit, or underscore that is not to be interpreted
  202. Xas part of its name.
  203. XIf \fIname\fP is an array parameter, then the values of each
  204. Xelement of \fIname\fP is substituted, one element per word.
  205. XOtherwise, the expansion results in one word only; no
  206. Xword splitting is done on the result.
  207. X.TP
  208. X\fB${\fIname\fB:\-\fIword\fB}\fR
  209. XIf \fIname\fP is set and is non-null then substitute its
  210. Xvalue; otherwise substitute \fIword\fP.
  211. X.TP
  212. X\fB${\fIname\fB:=\fIword\fB}\fR
  213. XIf \fIname\fP is unset and is null then
  214. Xset it to \fIword\fP; the value of the parameter is then
  215. Xsubstituted.
  216. X.TP
  217. X\fB${\fIname\fB:?\fIword\fB}\fR
  218. XIf \fIname\fP is set and is non-null, then substitute
  219. Xits value; otherwise, print \fIword\fP and exit from the shell.
  220. XIf \fIword\fP is omitted, then a standard message is printed.
  221. X.TP
  222. X\fB${\fIname\fB:+\fIword\fB}\fR
  223. XIf \fIname\fP is set and is non-null then substitute
  224. X\fIword\fP; otherwise substitute nothing.
  225. X.PD 0
  226. X.TP
  227. X\fB${\fIname\fB#\fIpattern\fB}\fR
  228. X.TP
  229. X\fB${\fIname\fB##\fIpattern\fB}\fR
  230. X.PD
  231. XIf the \fIpattern\fP matches the beginning of the value of
  232. X\fIname\fP, then substitute the value of \fIname\fP with
  233. Xthe matched portion deleted; otherwise, just
  234. Xsubstitute the value of \fIname\fP.  In the first
  235. Xform, the smallest matching pattern is preferred;
  236. Xin the second form, the largest matching pattern is preferred.
  237. X.PD 0
  238. X.TP
  239. X${\fIname\fB%\fIpattern\fR}
  240. X.TP
  241. X${\fIname\fB%%\fIpattern\fR}
  242. X.PD
  243. XIf the \fIpattern\fP matches the end of the value of
  244. X\fIname\fP, then substitute the value of \fIname\fP with
  245. Xthe matched portion deleted; otherwise, just
  246. Xsubstitute the value of \fIname\fP.  In the first
  247. Xform, the smallest matching pattern is preferred;
  248. Xin the second form, the largest matching pattern is preferred.
  249. X.TP
  250. X${\fB#\fIspec\fR}
  251. XIf \fIspec\fP is one of the above substitutions, substitute
  252. Xthe length in characters of the result instead of
  253. Xthe result itself.  If \fIspec\fP is an array expression,
  254. Xsubstitute the number of elements of the result.
  255. X.TP
  256. X${\fB^\fIspec\fR}
  257. XToggle the value of the \fBRC_EXPAND_PARAM\fP option for the
  258. Xevaluation of \fIspec\fP.
  259. XWhen this option is set, array expansions of the form
  260. X\fIfoo\fB${\fIxx\fB}\fIbar\fR, where the parameter
  261. X\fIxx\fP is set to (\fIa b c\fP), are substituted with
  262. X\fIfooabar foobbar foocbar\fP instead of the default
  263. X\fIfooa b cbar\fP.
  264. X.TP
  265. X${\fB=\fIspec\fR}
  266. XToggle the value of the \fBSH_WORD_SPLIT\fP option for the
  267. Xevaluation of \fIspec\fP.
  268. XWhen this option is set, parameter values are split into
  269. Xseparate words using \fBIFS\fP as a delimiter
  270. Xbefore substitution.
  271. XThis is done by default in most other shells.
  272. X.PD
  273. X.RE
  274. X.PP
  275. XIf the colon is omitted from one of the above expressions
  276. Xcontaining a colon, then the shell only checks whether
  277. X\fIname\fP is set or not, not whether it is null.
  278. X.SS Command Substitution
  279. XA command enclosed in parentheses
  280. Xpreceded by a dollar sign, like so: $(...) or quoted with grave
  281. Xaccents: `...` is replaced with its standard output.
  282. XIf the substitution is not enclosed in double quotes, the
  283. Xoutput is broken into words using the \fBIFS\fP parameter.
  284. XThe substitution \fB$(cat foo)\fP may be replaced
  285. Xby the equivalent but faster \fB$(<foo)\fP.
  286. X.SS Arithmetic Expansion
  287. XA string of the form \fB$[\fIexp\fB]\fR is substituted
  288. Xwith the value of the arithmetic expression \fIexp\fP.
  289. X\fIexp\fP is treated as if it were within single quotes.
  290. XSee \fBARITHMETIC EVALUATION\fP below.
  291. X.SS Brace Expansion
  292. XA string of the form
  293. X\fIfoo\fB{\fIxx\fB,\fIyy\fB,\fIzz\fB}\fIbar\fR
  294. Xis expanded to the individual words
  295. X\fIfooxxbar\fP, \fIfooyybar\fP, and \fIfoozzbar\fP.
  296. XLeft-to-right order is preserved.  This construct
  297. Xmay be nested.  Malformed brace expansion expressions,
  298. Xincluding expressions without a comma, are left unchanged
  299. Xby the shell.
  300. X.PP
  301. XAn expression of the form
  302. X\fB{\fIx\fB\-\fIy\fB}\fR,
  303. Xwhere \fIx\fP and \fIy\fP are single characters,
  304. Xis expanded to every character between
  305. X\fIx\fP and \fIy\fP, inclusive.
  306. X.SS Filename Generation
  307. XIf a word contains an unquoted instance of one of the characters
  308. X*, |, <, [, or ?, or the string "****/", it is regarded
  309. Xas a pattern for filename generation, unless the \fBNOGLOB\fP option is set.
  310. XIf the \fBEXTENDED_GLOB\fP option is set, the
  311. X^ and # characters also denote a pattern; otherwise
  312. Xthey are not treated specially by the shell.
  313. XThe word is replaced with a list of sorted filenames that match
  314. Xthe pattern.  If no matching pattern is found, the shell gives
  315. Xan error message, unless the \fBNULLGLOB\fP option is set,
  316. Xin which case the word is deleted; or unless the \fBNO_NOMATCH\fP
  317. Xoption is set, in which case the word is left unchanged.
  318. XIn filename generation,
  319. Xthe character / must be matched explicitly; also, a . must be matched
  320. Xexplicitly at the beginning of a pattern or after a /, unless the
  321. X\fBGLOBDOTS\fP option is set.  No filename generation pattern
  322. Xmatches the files "." or "..".  In other instances of pattern
  323. Xmatching, the / and . are not treated specially.
  324. X.PP
  325. X.RS
  326. X.PD 0
  327. X.TP
  328. X.B *
  329. Xmatches any string, including the null string.
  330. X.TP
  331. X.B ?
  332. Xmatches any character.
  333. X.TP
  334. X\fB[ ... ]\fP
  335. Xmatches any of the enclosed characters.
  336. X.TP
  337. X\fB[^ ... ]\fP
  338. Xmatches any character except the enclosed characters.
  339. X.TP
  340. X\fB<x\-y>\fP
  341. Xmatches any number in the range x to y, inclusive.
  342. XIf x is omitted, the number must be less than or equal to y.
  343. XIf y is omitted, the number must be greater than or equal to x.
  344. XA pattern of the form \fB<\->\fP or
  345. Xsimply \fB<>\fP matches any number.
  346. X.TP
  347. X\fB^x\fP
  348. Xmatches anything except the pattern x.
  349. X.TP
  350. X\fBx|y\fP
  351. Xmatches either x or y.
  352. X.TP
  353. X\fBx#\fP
  354. Xmatches zero or more occurrences of the pattern x.
  355. X.TP
  356. X\fBx##\fP
  357. Xmatches one or more occurrences of the pattern x.
  358. X.RE
  359. X.PD
  360. X.PP
  361. XParentheses may be used for grouping.  Note that the \fB|\fP character
  362. Xmust be within parentheses, so that the lexical analyzer does
  363. Xnot think it is a pipe character.  Also note that "/" has a
  364. Xhigher precedence than "^"; that is:
  365. X.RS
  366. X.PP
  367. Xls
  368. X.BI ^ foo / bar
  369. X.RE
  370. X.PP
  371. Xwill search directories in "." except "./foo" for a file named bar.
  372. X.PP
  373. XA pathname component of the form
  374. X.BI ( foo /)#
  375. Xmatches a path consisting of zero or more directories
  376. Xmatching the pattern foo.
  377. XAs a shorthand,
  378. X.B ****/
  379. Xis equivalent to
  380. X.BR (*/)# .
  381. XThus:
  382. X.RS
  383. X.PP
  384. Xls
  385. X.BI (*/)# bar
  386. X.RE
  387. X.PP
  388. Xor
  389. X.RS
  390. X.PP
  391. Xls
  392. X.BI ****/ bar
  393. X.RE
  394. X.PP
  395. Xdoes a recursive directory search for files named bar.
  396. X.PP
  397. XIf used for filename generation, a pattern may end in a
  398. Xlist of qualifiers enclosed in parentheses.
  399. XThe qualifiers
  400. Xspecify which filenames that otherwise match the given pattern
  401. Xwill be inserted in the argument list.
  402. XA qualifier may be any one of the following:
  403. X.PD 0
  404. X.RS
  405. X.TP
  406. X.B /
  407. Xdirectories
  408. X.TP
  409. X.B .
  410. Xplain files
  411. X.TP
  412. X.B @
  413. Xsymbolic links
  414. X.TP
  415. X.B =
  416. Xsockets
  417. X.TP
  418. X.B p
  419. Xnamed pipes (FIFOs)
  420. X.TP
  421. X.B *
  422. Xexecutable plain files (0100)
  423. X.TP
  424. X.B %
  425. Xdevice files (character or block special)
  426. X.TP
  427. X.B r
  428. Xreadable files (0400)
  429. X.TP
  430. X.B w
  431. Xwritable files (0200)
  432. X.TP
  433. X.B x
  434. Xexecutable files (0100)
  435. X.TP
  436. X.B R
  437. Xworld-readable files (0004)
  438. X.TP
  439. X.B W
  440. Xworld-writable files (0002)
  441. X.TP
  442. X.B X
  443. Xworld-executable files (0001)
  444. X.TP
  445. X.B s
  446. Xsetuid files (04000)
  447. X.TP
  448. X.B S
  449. Xsetgid files (02000)
  450. X.TP
  451. X\fBd\fIdev\fR
  452. Xfiles on the device \fIdev\fP
  453. X.TP
  454. X\fBl\fIct\fR
  455. Xfiles having a link count of \fIct\fP
  456. X.TP
  457. X\fBU\fP
  458. Xfiles owned by the effective user id
  459. X.TP
  460. X\fBG\fP
  461. Xfiles owned by the effective group id
  462. X.TP
  463. X\fBu\fInum\fR
  464. Xfiles owned by user id \fInum\fP
  465. X.TP
  466. X\fBg\fInum\fR
  467. Xfiles owned by group id \fInum\fP
  468. X.TP
  469. X\fB^\fP
  470. Xnegates all qualifiers following it
  471. X.PD
  472. X.RE
  473. X.PP
  474. XThus:
  475. X.RS
  476. X.PP
  477. Xls
  478. X.B
  479. X*(%W)
  480. X.RE
  481. X.PP
  482. Xlists all world-writable device files in the current directory,
  483. Xand
  484. X.RS
  485. X.PP
  486. Xls
  487. X.B /tmp/foo*(u0^@)
  488. X.RE
  489. X.PP
  490. Xlists all root-owned files beginning with the string
  491. X"foo" in /tmp, ignoring symlinks.  A "/" at the end of a pattern
  492. Xis equivalent to "(\|/\|)".
  493. X.SH REDIRECTION
  494. XBefore a command is executed, its input and output
  495. Xmay be redirected.
  496. XThe following may appear anywhere in a simple-command
  497. Xor may precede or follow a complex command.
  498. XSubstitution occurs before
  499. X.I word
  500. Xis used except as noted below.
  501. XIf the result of substitution on
  502. X.I word
  503. Xproduces more than one filename,
  504. Xredirection occurs for each
  505. Xseparate filename in turn.
  506. X.TP
  507. X.BI < word
  508. XOpen file
  509. X.I word
  510. Xas standard input.
  511. X.TP
  512. X.BI > word
  513. XOpen file
  514. X.I word
  515. Xas standard output.
  516. XIf the file does not exist then it is created.
  517. XIf the file exists, and the
  518. X.B NOCLOBBER
  519. Xoption is set,
  520. Xthis causes an error;
  521. Xotherwise, it is truncated to zero length.
  522. X.TP
  523. X.BI >! " word"
  524. XSame as
  525. X.BR > ,
  526. Xexcept that the file is truncated to zero length
  527. Xif it exists, even if
  528. X.B NOCLOBBER
  529. Xis set.
  530. X.TP
  531. X.BI >> word
  532. XOpen file
  533. X.I word
  534. Xas standard output.
  535. XIf the file exists then output is appended to it.
  536. XIf the file does not exist, and the
  537. X.B NOCLOBBER
  538. Xoption is set,
  539. Xthis causes an error;
  540. Xotherwise, the file is created.
  541. X.TP
  542. X.BI >>! " word"
  543. XSame as
  544. X.BR >> ,
  545. Xexcept that the file is created if it does not
  546. Xexist, even if
  547. X.B NOCLOBBER
  548. Xis set.
  549. X.TP
  550. X\fB<<\fP[\-] \fIword\fP
  551. XThe shell input is read up to a line that is the same as
  552. X.IR word ,
  553. Xor to an end-of-file.
  554. XNo parameter substitution, command substitution or
  555. Xfilename generation is performed on
  556. X.IR word .
  557. XThe resulting document,
  558. Xcalled a
  559. X.IR here-document ,
  560. Xbecomes
  561. Xthe standard input.
  562. XIf any character of \fIword\fP is quoted with
  563. Xsingle or double quotes (a \e alone is \fInot\fP sufficient),
  564. Xno interpretation
  565. Xis placed upon the characters of the document.
  566. XOtherwise, parameter and command substitution
  567. Xoccurs, \e followed by a newline is removed,
  568. Xand \e must be used to quote the characters
  569. X\e, $, `, and the first character of \fIword\fP.
  570. XIf <<\- is used, then all leading
  571. Xtabs are stripped from \fIword\fP and from the document.
  572. X.TP
  573. X.BI <<< word
  574. XOpen a file containing \fIword\fP, after expansion,
  575. Xas standard input.
  576. X.TP
  577. X.BI <& digit
  578. XThe standard input
  579. Xis duplicated from file descriptor
  580. X.I digit
  581. X(see
  582. X.IR dup (2)).
  583. XSimilarly for standard output using
  584. X\fB>&\fIdigit\fP.
  585. X.TP
  586. X.BI >& word
  587. XSame as
  588. X.BI > word
  589. X\fB2>&\fP1.
  590. X.TP
  591. X.BI >>& word
  592. XSame as
  593. X.BI >> word
  594. X\fB2>&\fP1.
  595. X.TP
  596. X.BI <&\-
  597. XClose the standard input.
  598. X.TP
  599. X.BI >&\-
  600. XClose the standard output.
  601. X.TP
  602. X.BI <&p
  603. XThe input from the coprocess is moved to the standard input.
  604. X.TP
  605. X.BI >&p
  606. XThe output to the coprocess is moved to the standard output.
  607. X.PP
  608. XIf one of the above is preceded by a digit, then the file
  609. Xdescriptor referred to is that specified by the digit
  610. X(instead of the default 0 or 1).
  611. XThe order in which redirections are specified is significant.
  612. Xthe shell evaluates each redirection in terms of the
  613. X.RI ( "file descriptor" ", " file )
  614. Xassociation at the time of evaluation.
  615. XFor example:
  616. X.RS
  617. X.PP
  618. X\&.\|.\|. \|1>\fIfname\^\fP 2>&1
  619. X.RE
  620. X.PP
  621. Xfirst associates file descriptor 1 with file
  622. X.IR fname .
  623. XIt then associates file descriptor 2 with the file associated with file
  624. Xdescriptor 1 (that is,
  625. X.IR fname ).
  626. XIf the order of redirections were reversed, file descriptor 2 would be associated
  627. Xwith the terminal (assuming file descriptor 1 had been) and then file descriptor
  628. X1 would be associated with file
  629. X.IR fname .
  630. X.PP
  631. XIf the user tries to open a file descriptor for writing more than once,
  632. Xthe shell opens the file descriptor as a pipe to a process that copies
  633. Xits input to all the specified outputs, similar to tee(1).  Thus:
  634. X.RS
  635. X.PP
  636. X.B date >foo >bar
  637. X.RE
  638. X.PP
  639. Xwrites the date to two files, named "foo" and "bar".
  640. XNote that a pipe is an implicit indirection; thus
  641. X.RS
  642. X.PP
  643. X.B date >foo | cat
  644. X.RE
  645. X.PP
  646. Xwrites the date to the file "foo", and also pipes it to cat.
  647. X.PP
  648. XIf the user tries to open a file descriptor for reading more than once,
  649. Xthe shell opens the file descriptor as a pipe to a process that copies
  650. Xall the specified inputs to its output in the order
  651. Xspecified, similar to cat(1).  Thus
  652. X.RS
  653. X.PP
  654. X.B sort <foo <fubar
  655. X.RE
  656. X.PP
  657. Xor even
  658. X.RS
  659. X.PP
  660. X.B sort <f{oo,ubar}
  661. X.RE
  662. X.PP
  663. Xis equivalent to "cat foo bar | sort".  Note that
  664. Xa pipe is in implicit indirection; thus
  665. X.RS
  666. X.PP
  667. X.B cat bar | sort <foo
  668. X.RE
  669. X.PP
  670. Xis equivalent to "cat bar foo | sort" (note the order of the inputs).
  671. X.PP
  672. XIf a simple command consists of one or more redirection operators
  673. Xand zero or more parameter assignments, but no command name,
  674. Xthe command \fBcat\fP is assumed.  Thus
  675. X.RS
  676. X.PP
  677. X.B < file
  678. X.RE
  679. X.PP
  680. Xprints the contents of \fBfile\fP.
  681. X.PP
  682. XIf a command is followed by
  683. X.B &
  684. Xand job control is not active,
  685. Xthen the default standard input
  686. Xfor the command
  687. Xis the empty file
  688. X.BR /dev/null .
  689. XOtherwise, the environment for the execution of a command contains the
  690. Xfile descriptors of the invoking shell as modified by
  691. Xinput/output specifications.
  692. X.SH "COMMAND EXECUTION"
  693. XIf a command name contains no slashes, the shell attempts to locate
  694. Xit.  If there exists a shell function by that name, the function
  695. Xis invoked as described below in \fBFUNCTIONS\fP.  If there exists
  696. Xa shell builtin by that name, the builtin is invoked.
  697. X.PP
  698. XOtherwise, the shell searches each element of \fBpath\fP for a
  699. Xdirectory containing an executable file by that name.  If the
  700. Xsearch is unsuccessful, the shell prints an error message and returns
  701. Xa nonzero exit status.
  702. X.PP
  703. XIf execution fails because the file is not in executable format,
  704. Xand the file is not a directory, it is assumed to be a shell
  705. Xscript.  /bin/sh is spawned to execute it.  If the program
  706. Xis a file beginning with \fB#!\fP, the remainder of the first line
  707. Xspecifies an interpreter for the program.  The shell will
  708. Xexecute the specified interpreter on operating systems that do
  709. Xnot handle this executable format in the kernel.
  710. X.SH FUNCTIONS
  711. X.PP
  712. XThe
  713. X.B function
  714. Xreserved word is used to define shell functions.
  715. XShell functions are read in and stored internally.
  716. XAlias names are resolved when the function is read.
  717. XFunctions are executed like commands with the arguments
  718. Xpassed as positional parameters.
  719. X(See
  720. X.I Execution
  721. Xbelow).
  722. X.PP
  723. XFunctions execute in the same process as the caller and
  724. Xshare all files
  725. Xand present working directory with the
  726. Xcaller.
  727. XA trap on
  728. X.B EXIT
  729. Xset inside a function
  730. Xis executed after the function completes in the environment
  731. Xof the caller.
  732. X.PP
  733. XThe
  734. X.B return
  735. Xbuiltin is used to return
  736. Xfrom function calls.
  737. X.PP
  738. XFunction identifiers
  739. Xcan be listed with the
  740. X.B functions
  741. Xbuiltin.
  742. XFunctions can be undefined with the
  743. X.B unfunction
  744. Xbuiltin.
  745. X.PP
  746. XThe following functions, if defined, have special meaning to
  747. Xthe shell:
  748. X.PP
  749. X.PD 0
  750. X.TP
  751. X\fBchpwd\fP
  752. XExecuted whenever the current working directory is changed.
  753. X.TP
  754. X\fBprecmd\fP
  755. XExecuted before each prompt.
  756. X.TP
  757. X\fBperiodic\fP
  758. XIf the parameter
  759. X.B PERIOD
  760. Xis set, this function is executed every
  761. X.B PERIOD
  762. Xseconds, just before a prompt.
  763. X.TP
  764. X\fBTRAPxxx\fP
  765. XIf defined and non-null,
  766. Xthis function will be executed whenever the shell
  767. Xcatches a signal \fBSIGxxx\fP, where \fBxxx\fP is a signal
  768. Xname as specified for the \fBkill\fP builtin (see below).
  769. XIn addition, \fBTRAPERR\fP is executed whenever a command has a non-zero
  770. Xexit status, \fBTRAPDEBUG\fP is executed after each command, and
  771. X\fBTRAPEXIT\fP
  772. Xis executed when the shell exits,
  773. Xor when the current function exits if defined
  774. Xinside a function.
  775. XIf a function of this form is defined and null,
  776. Xthe shell and processes spawned by it will ignore \fBSIGxxx\fP.
  777. X.PD
  778. X.SH JOBS
  779. X.PP
  780. XIf the
  781. X.B MONITOR
  782. Xoption is set,
  783. Xan interactive shell associates a \fIjob\fR with each pipeline.
  784. XIt keeps
  785. Xa table of current jobs, printed by the
  786. X.B jobs
  787. Xcommand, and assigns them small integer numbers.
  788. XWhen a job is started asynchronously with
  789. X.BR & ,
  790. Xthe shell prints a line which looks
  791. Xlike:
  792. X.PP
  793. X.DT
  794. X    [1] 1234
  795. X.PP
  796. Xindicating that the job which was started asynchronously was job number
  797. X1 and had one (top-level) process, whose process id was 1234.
  798. X.PP
  799. XIf you are running a job and wish to do something else you may hit the key
  800. X\fB^Z\fR (control-Z) which sends a STOP signal to the current job.
  801. Xthe shell will then normally indicate that the job has been `suspended',
  802. Xand print another prompt.
  803. XYou can then manipulate the state of this job,
  804. Xputting it in the background with the
  805. X.B bg
  806. Xcommand, or run some other
  807. Xcommands and then eventually bring the job back into the foreground with
  808. Xthe foreground command
  809. X.BR fg .
  810. XA \fB^Z\fR takes effect immediately and
  811. Xis like an interrupt in that pending output and unread input are discarded
  812. Xwhen it is typed.
  813. X.PP
  814. XA job being run in the background will suspend if it tries to read
  815. Xfrom the terminal.
  816. XBackground jobs are normally allowed to produce output,
  817. Xbut this can be disabled by giving the command ``stty tostop''.
  818. XIf you set this
  819. Xtty option, then background jobs will suspend when they try to produce
  820. Xoutput like they do when they try to read input.
  821. X.PP
  822. XThere are several ways to refer to jobs in the shell.
  823. XA job can be referred to by the process id of any process of the job
  824. Xor by one of the following:
  825. X.PD 0
  826. X.TP
  827. X.BI % number
  828. XThe job with the given number.
  829. X.TP
  830. X.BI % string
  831. XAny job whose command line begins with
  832. X.IR string .
  833. X.TP
  834. X.BI %? string
  835. XAny job whose command line contains
  836. X.IR string .
  837. X.TP
  838. X.BI %%
  839. XCurrent job.
  840. X.TP
  841. X.BI %+
  842. XEquivalent to
  843. X.BR %% .
  844. X.TP
  845. X.BI %\-
  846. XPrevious job.
  847. X.PD
  848. X.PP
  849. XThe shell learns immediately whenever a process changes state.
  850. XIt normally informs you whenever a job becomes blocked so that
  851. Xno further progress is possible.  If
  852. X.B notify
  853. Xis not set, it waits until
  854. Xjust before it prints
  855. Xa prompt before it informs you.
  856. X.PP
  857. XWhen the monitor mode is on, each background job that completes
  858. Xtriggers any trap set for
  859. X.BR CHLD .
  860. X.PP
  861. XWhen you try to leave the shell while jobs are running or suspended, you will
  862. Xbe warned that `You have suspended (running) jobs.'
  863. XYou may use the
  864. X.B jobs
  865. Xcommand to see what they are.
  866. XIf you do this or immediately try to
  867. Xexit again, the shell will not warn you a second time; the suspended
  868. Xjobs will be terminated, and the running jobs will be sent
  869. Xa \fBSIGHUP\fP signal.
  870. XTo avoid having the shell terminate the running jobs, either
  871. Xuse the \fBnohup\fP(1) command or the \fBdisown\fP builtin (see below).
  872. X.SH SIGNALS
  873. XThe INT and QUIT signals for an invoked
  874. Xcommand are ignored if the command is followed by
  875. X.B &
  876. Xand job
  877. X.B monitor
  878. Xoption is not active.
  879. XOtherwise, signals have the values
  880. Xinherited by the shell from its parent
  881. X(but see the \fBTRAPxxx\fP special function above).
  882. X.SH HISTORY
  883. XHistory substitution allows you to use words from previous command
  884. Xlines in the command line you are typing.  This simplifies spelling
  885. Xcorrections and the repetition of complicated commands or arguments.
  886. XCommand lines are saved in the history list, the size of which
  887. Xis controlled by the
  888. X.B HISTSIZE
  889. Xvariable.  The most recent command is retained in any case.
  890. XA history substitution begins with a
  891. X.B !
  892. Xand may occur anywhere on the command line; history
  893. Xsubstitutions do not nest.  The
  894. X.B !
  895. Xcan be escaped with
  896. X.B \e
  897. Xto suppress its special meaning.
  898. XSingle or double quotes will \fInot\fP work for this.
  899. X.PP
  900. XInput lines containing history substitutions are echoed on the
  901. Xterminal after being expanded, but before any other
  902. Xsubstitutions take place or the command gets executed.
  903. X.SS Event Designators
  904. X.PP
  905. XAn event designator is a reference to a command-line entry in
  906. Xthe history list.
  907. X.RS
  908. X.PD 0
  909. X.TP
  910. X.B !
  911. XStart a history substitution, except when followed by a blank, newline,
  912. X.BR = ,
  913. Xor
  914. X.BR ( .
  915. X.TP
  916. X.B !!
  917. XRefer to the previous command. 
  918. XBy itself, this substitution
  919. Xrepeats the previous command.
  920. X.TP
  921. X.BI ! n
  922. XRefer to command-line
  923. X.IR n .
  924. X.TP
  925. X.BI ! \-n
  926. XRefer to the current command-line minus
  927. X.IR n .
  928. X.TP
  929. X.BI  ! str
  930. XRefer to the most recent command starting with
  931. X.IR str .
  932. X.TP
  933. X.BI  !? str\fR[\fP ? \fR]\fP
  934. XRefer to the most recent command containing
  935. X.IR str .
  936. X.TP
  937. X.B !#
  938. XRefer to the current command line typed in so far.
  939. X.TP
  940. X.BR !{ .\|.\|. }
  941. XInsulate a history reference from adjacent characters (if necessary).
  942. X.PD
  943. X.RE
  944. X.SS Word Designators
  945. X.PP
  946. XA
  947. X.RB ` : '
  948. Xseparates the event specification from the word designator. 
  949. XIt can be omitted if the word designator begins with a
  950. X.BR \*^ ,
  951. X.BR $ ,
  952. X.BR * ,
  953. X.B \-
  954. Xor
  955. X.BR % .
  956. XIf the word is to be selected from the previous command, the second
  957. X.B !
  958. Xcharacter can be omitted from the event specification.  For instance,
  959. X.B !!:1
  960. Xand
  961. X.B !:1
  962. Xboth refer to the first word of the previous command, while
  963. X.B !!$
  964. Xand
  965. X.B !$
  966. Xboth refer to the last word in the previous command. 
  967. XWord designators include:
  968. X.RS
  969. X.PD 0
  970. X.TP
  971. X.B 0
  972. XThe first input word (command).
  973. X.TP
  974. X.I n
  975. XThe
  976. X.IR n 'th
  977. Xargument.
  978. X.TP
  979. X.B ^
  980. XThe first argument, that is,
  981. X.BR 1 .
  982. X.TP
  983. X.B $
  984. XThe last argument.
  985. X.TP
  986. X.B %
  987. XThe word matched by (the most recent)
  988. X.BI ? s
  989. Xsearch.
  990. X.TP
  991. X.IB x \- y
  992. XA range of words;
  993. X.BI \- y
  994. Xabbreviates
  995. X.BI 0\- y\fR.
  996. X.TP
  997. X.B *
  998. XAll the arguments, or a null value if there is just
  999. Xone word in the event.
  1000. X.TP
  1001. X.IB x *
  1002. XAbbreviates
  1003. X.IB x \-$ .
  1004. X.TP
  1005. X.IB x \-
  1006. XLike
  1007. X.I x*
  1008. Xbut omitting word
  1009. X.BR $ .
  1010. X.PD
  1011. X.RE
  1012. X.SS Modifiers
  1013. X.PP
  1014. XAfter the optional word designator, you can add
  1015. Xa sequence of one or more of the following modifiers,
  1016. Xeach preceded by a
  1017. X.BR : .
  1018. XThese modifiers also work on the result
  1019. Xof filename and parameter expansion.
  1020. X.RS
  1021. X.TP
  1022. X.B h
  1023. XRemove a trailing pathname component, leaving the head.
  1024. X.PD 0
  1025. X.TP
  1026. X.B r
  1027. XRemove a trailing suffix of the form
  1028. X.RB ` "\&.\fIxxx" ',
  1029. Xleaving the basename.
  1030. X.TP
  1031. X.B e
  1032. XRemove all but the suffix.
  1033. X.TP
  1034. X.B t
  1035. XRemove all leading pathname components, leaving the tail.
  1036. X.TP
  1037. X.B &
  1038. XRepeat the previous substitution.
  1039. X.TP
  1040. X.B g
  1041. XApply the change to the first occurrence of a match in each word,
  1042. Xby prefixing the above (for example,
  1043. X.BR g& ).
  1044. X.TP
  1045. X.B p
  1046. XPrint the new command but do not execute it.
  1047. X.TP
  1048. X.B q
  1049. XQuote the substituted words, escaping further substitutions.
  1050. X.TP
  1051. X.B x
  1052. XLike
  1053. X.BR q ,
  1054. Xbut break into words at each blank.
  1055. X.TP
  1056. X.B l
  1057. XConvert the words to all lowercase.
  1058. X.TP
  1059. X.B u
  1060. XConvert the words to all uppercase.
  1061. X.TP
  1062. X.BI s/ l / r\fR[\fP / \fR]\fP
  1063. XSubstitute
  1064. X.I r
  1065. Xfor
  1066. X.IR l .
  1067. X.PD
  1068. X.RE
  1069. X.PP
  1070. XUnless preceded by a
  1071. X.BR g ,
  1072. Xthe substitution is done only for the
  1073. Xfirst string that matches
  1074. X.IR l .
  1075. X.PP
  1076. XThe left-hand side of substitutions are not regular expressions,
  1077. Xbut character strings.
  1078. XAny character can be used as the delimiter in place of
  1079. X.BR / .
  1080. XA backslash quotes the delimiter character.
  1081. XThe character
  1082. X.BR & ,
  1083. Xin the right hand side, is replaced by the text
  1084. Xfrom the left-hand-side. 
  1085. XThe
  1086. X.B &
  1087. Xcan be quoted with a backslash. 
  1088. XA null
  1089. X.I l
  1090. Xuses the previous string either from a
  1091. X.I l
  1092. Xor from a contextual scan string
  1093. X.I s
  1094. Xfrom
  1095. X.BI !? s\fR.
  1096. XYou can omit the rightmost delimiter if a newline
  1097. Ximmediately follows
  1098. X.IR r ;
  1099. Xthe rightmost
  1100. X.B ?
  1101. Xin a context scan can similarly be omitted.
  1102. X.PP
  1103. XWithout an event specification, a history reference refers either to the
  1104. Xprevious command, or to a previous history reference on the command line
  1105. X(if any).
  1106. X.PP
  1107. XThe character sequence
  1108. X.BI ^ foo ^ bar
  1109. Xrepeats the last command, replacing the string "foo" with the
  1110. Xstring "bar".
  1111. X.PP
  1112. XIf the shell encounters the character sequence
  1113. X\fB!"\fP
  1114. Xin the input, the history mechanism is temporarily disabled until
  1115. Xthe current list is fully parsed.  The
  1116. X\fB!"\fP
  1117. Xis removed from the input, and any subsequent
  1118. X.B !
  1119. Xcharacters have no special significance.
  1120. X.PP
  1121. XA less convenient but more comprehensible
  1122. Xform of command history support
  1123. Xis provided by the
  1124. X.B fc
  1125. Xbuiltin (see below).
  1126. X.SH "ARITHMETIC EVALUATION"
  1127. XAn ability to perform integer arithmetic
  1128. Xis provided with the builtin
  1129. X.BR let .
  1130. XEvaluations are performed using
  1131. X.I long
  1132. Xarithmetic.
  1133. XConstants are of the form
  1134. X[\fIbase\fB#\^\fR]\fIn\^\fP
  1135. Xwhere
  1136. X.I base
  1137. Xis a decimal number between two and thirty-six
  1138. Xrepresenting the arithmetic base
  1139. Xand
  1140. X.I n
  1141. Xis a number in that base.
  1142. XIf
  1143. X.I base
  1144. Xis omitted
  1145. Xthen base 10 is used.
  1146. X.PP
  1147. XAn arithmetic expression uses nearly the same syntax, precedence, and
  1148. Xassociativity of
  1149. Xexpressions in C.
  1150. XThe following operators are supported (listed in decreasing order
  1151. Xof precedence):
  1152. X.PP
  1153. X.PD 0
  1154. X.RS
  1155. X.TP
  1156. X.B + \- ! \(ap ++ \-\|\-
  1157. Xunary plus/minus, logical NOT, complement, {pre,post}{in,de}crement
  1158. X.TP
  1159. X.B &
  1160. Xlogical AND
  1161. X.TP
  1162. X.B ^
  1163. Xlogical XOR
  1164. X.TP
  1165. X.B |
  1166. Xlogical OR
  1167. X.TP
  1168. X.B * / %
  1169. Xmultiplication, division, remainder
  1170. X.TP
  1171. X.B + \-
  1172. Xaddition, subtraction
  1173. X.TP
  1174. X.B << >>
  1175. Xlogical shift left, shift right
  1176. X.TP
  1177. X.B < > <= >=
  1178. Xcomparison
  1179. X.TP
  1180. X.B == !=
  1181. Xequality and inequality
  1182. X.TP
  1183. X.B &&
  1184. Xboolean AND
  1185. X.TP
  1186. X.B |\|| ^^
  1187. Xboolean OR, XOR
  1188. X.TP
  1189. X.B ? :
  1190. Xternary operator
  1191. X.TP
  1192. X.B
  1193. X= += \-= *= /= %= &= ^= |= <<= >>= &&= |\||= ^^=
  1194. Xassignment
  1195. X.TP
  1196. X.B ,
  1197. Xcomma operator
  1198. X.PD
  1199. X.RE
  1200. X.PP
  1201. XThe operators &&, |\||, &&=, and |\||= are short-circuiting,
  1202. Xand only one of the latter two expressions in a ternary operator
  1203. Xis evaluated.  Note the precedence of the logical AND, OR,
  1204. Xand XOR operators.
  1205. X.PP
  1206. XNamed parameters can be referenced by name within an arithmetic expression
  1207. Xwithout using the parameter substitution syntax.
  1208. X.PP
  1209. XAn internal integer representation of a named parameter
  1210. Xcan be specified with the
  1211. X.B integer
  1212. Xbuiltin.
  1213. XArithmetic evaluation is performed on the value of each
  1214. Xassignment to a named parameter declared integer
  1215. Xin this manner.
  1216. X.PP
  1217. XSince many of the arithmetic operators require
  1218. Xquoting, an alternative form of the
  1219. X.B let
  1220. Xcommand is provided.
  1221. XFor any command which begins with a
  1222. X.BR (( ,
  1223. Xall the characters until a matching
  1224. X.B ))
  1225. Xare treated as a quoted expression.
  1226. XMore precisely,
  1227. X.BR (( ... ))
  1228. Xis equivalent to
  1229. X.B let
  1230. X\fB"\fP...\fB"\fP.
  1231. X.SH "CONDITIONAL EXPRESSIONS"
  1232. XA \fIconditional expression\fP is used with the
  1233. X.B [[
  1234. Xcompound command to test attributes of files and to compare strings.
  1235. XEach expression can be constructed from one or more
  1236. Xof the following unary or binary expressions:
  1237. X.PD 0
  1238. X.TP
  1239. X\fB\-a\fP \fIfile\fP
  1240. Xtrue if
  1241. X.I file
  1242. Xexists.
  1243. X.TP
  1244. X\fB\-b\fP \fIfile\fP
  1245. Xtrue if
  1246. X.I file
  1247. Xexists and is a block special file.
  1248. X.TP
  1249. X\fB\-c\fP \fIfile\fP
  1250. Xtrue if
  1251. X.I file
  1252. Xexists and is a character special file.
  1253. X.TP
  1254. X\fB\-d\fP \fIfile\fP
  1255. Xtrue if
  1256. X.I file
  1257. Xexists and is a directory.
  1258. X.TP
  1259. X\fB\-f\fP \fIfile\fP
  1260. Xtrue if
  1261. X.I file
  1262. Xexists and is an ordinary file.
  1263. X.TP
  1264. X\fB\-g\fP \fIfile\fP
  1265. Xtrue if
  1266. X.I file
  1267. Xexists and is has its setgid bit set.
  1268. X.TP
  1269. X\fB\-k\fP \fIfile\fP
  1270. Xtrue if
  1271. X.I file
  1272. Xexists and is has its sticky bit set.
  1273. X.TP
  1274. X\fB\-n\fP \fIstring\fP
  1275. Xtrue if length of
  1276. X.I string
  1277. Xis non-zero.
  1278. X.TP
  1279. X\fB\-o\fP \fIoption\fP
  1280. Xtrue if option named
  1281. X.I option
  1282. Xis on.
  1283. X.TP
  1284. X\fB\-p\fP \fIfile\fP
  1285. Xtrue if
  1286. X.I file
  1287. Xexists and is a fifo special file or a pipe.
  1288. X.TP
  1289. X\fB\-r\fP \fIfile\fP
  1290. Xtrue if
  1291. X.I file
  1292. Xexists and is readable by current process.
  1293. X.TP
  1294. X\fB\-s\fP \fIfile\fP
  1295. Xtrue if
  1296. X.I file
  1297. Xexists and has size greater than zero.
  1298. X.TP
  1299. X\fB\-t\fP \fIfd\fP
  1300. Xtrue if file descriptor number
  1301. X.I fd
  1302. Xis open and associated with a terminal device.
  1303. X(note: \fIfd\fP is not optional)
  1304. X.TP
  1305. X\fB\-u\fP \fIfile\fP
  1306. Xtrue if
  1307. X.I file
  1308. Xexists and is has its setuid bit set.
  1309. X.TP
  1310. X\fB\-w\fP \fIfile\fP
  1311. Xtrue if
  1312. X.I file
  1313. Xexists and is writable by current process.
  1314. X.TP
  1315. X\fB\-x\fP \fIfile\fP
  1316. Xtrue if
  1317. X.I file
  1318. Xexists and is executable by current process.
  1319. XIf
  1320. X.I file
  1321. Xexists and is a directory, then the current process
  1322. Xhas permission to search in the directory.
  1323. X.TP
  1324. X\fB\-z\fP \fIstring\fP
  1325. Xtrue if length of
  1326. X.I string
  1327. Xis zero.
  1328. X.TP
  1329. X\fB\-L\fP \fIfile\fP
  1330. Xtrue if
  1331. X.I file
  1332. Xexists and is a symbolic link.
  1333. X.TP
  1334. X\fB\-O\fP \fIfile\fP
  1335. Xtrue if
  1336. X.I file
  1337. Xexists and is owned by the effective user id of this process.
  1338. X.TP
  1339. X\fB\-G\fP \fIfile\fP
  1340. Xtrue if
  1341. X.I file
  1342. Xexists and its group matches the effective group id of this process.
  1343. X.TP
  1344. X\fB\-S\fP \fIfile\fP
  1345. Xtrue if
  1346. X.I file
  1347. Xexists and is a socket.
  1348. X.TP
  1349. X\fIfile1\fP \fB\-nt\fP \fIfile2\fP
  1350. Xtrue if
  1351. X.I file1
  1352. Xexists and is newer than
  1353. X.IR file2 .
  1354. X.TP
  1355. X\fIfile1\fP \fB\-ot\fP \fIfile2\fP
  1356. Xtrue if
  1357. X.I file1
  1358. Xexists and is older than
  1359. X.IR file2 .
  1360. X.TP
  1361. X\fIfile1\fP \fB\-ef\fP \fIfile2\fP
  1362. Xtrue if
  1363. X.I file1
  1364. Xand 
  1365. X.I file2
  1366. Xexist and refer to the same file.
  1367. X.TP
  1368. X\fIstring\fP \fB=\fP \fIpattern\fP
  1369. Xtrue if
  1370. X.I string
  1371. Xmatches
  1372. X.IR pattern .
  1373. X.TP
  1374. X\fIstring\fP \fB!=\fP \fIpattern\fP
  1375. Xtrue if
  1376. X.I string
  1377. Xdoes not match
  1378. X.IR pattern .
  1379. X.TP
  1380. X\fIstring1\fP \fB<\fP \fIstring2\fP
  1381. Xtrue if
  1382. X.I string1
  1383. Xcomes before
  1384. X.I string2
  1385. Xbased on ASCII value of their characters.
  1386. X.TP
  1387. X\fIstring1\fP \fB>\fP \fIstring2\fP
  1388. Xtrue if
  1389. X.I string1
  1390. Xcomes after
  1391. X.I string2
  1392. Xbased on ASCII value of their characters.
  1393. X.TP
  1394. X\fIexp1\fP \fB\-eq\fP \fIexp2\fP
  1395. Xtrue if
  1396. X.I exp1
  1397. Xis equal to
  1398. X.IR exp2.
  1399. X.TP
  1400. X\fIexp1\fP \fB\-ne\fP \fIexp2\fP
  1401. Xtrue if
  1402. X.I exp1
  1403. Xis not equal to
  1404. X.IR exp2.
  1405. X.TP
  1406. X\fIexp1\fP \fB\-lt\fP \fIexp2\fP
  1407. Xtrue if
  1408. X.I exp1
  1409. Xis less than
  1410. X.IR exp2.
  1411. X.TP
  1412. X\fIexp1\fP \fB\-gt\fP \fIexp2\fP
  1413. Xtrue if
  1414. X.I exp1
  1415. Xis greater than
  1416. X.IR exp2.
  1417. X.TP
  1418. X\fIexp1\fP \fB\-le\fP \fIexp2\fP
  1419. Xtrue if
  1420. X.I exp1
  1421. Xis less than or equal to
  1422. X.IR exp2.
  1423. X.TP
  1424. X\fIexp1\fP \fB\-ge\fP \fIexp2\fP
  1425. Xtrue if
  1426. X.I exp1
  1427. Xis greater than or equal to
  1428. X.IR exp2.
  1429. X.TP
  1430. X\fB(\fP \fIexp\fP \fB)\fP
  1431. Xtrue if \fIexp\fP is true.
  1432. X.TP
  1433. X\fB!\fP \fIexp\fP
  1434. Xtrue if \fIexp\fP is false.
  1435. X.TP
  1436. X\fIexp1\fP \fB&&\fP \fIexp2\fP
  1437. Xtrue if \fIexp1\fP and \fIexp2\fP are both true.
  1438. X.TP
  1439. X\fIexp1\fP \fB|\||\fP \fIexp2\fP
  1440. Xtrue if either \fIexp1\fP or \fIexp2\fP is true.
  1441. X.PD
  1442. X.PP
  1443. XIn each of the above expressions, if
  1444. X.I file
  1445. Xis of the form
  1446. X\fB/dev/fd/\fP\fIn\fR,
  1447. Xwhere
  1448. X.I n
  1449. Xis an integer,
  1450. Xthen the test applied to the open file whose
  1451. Xdescriptor number is
  1452. X.IR n ,
  1453. Xeven if the underlying system does not support
  1454. Xthe \fB/dev/fd\fP directory.
  1455. X.PD
  1456. X.SH "ZSH LINE EDITOR"
  1457. XIf the \fBZLE\fP option is set (it is by default)
  1458. Xand the shell input is attached to the terminal, the user
  1459. Xis allowed to edit command lines.
  1460. X.PP
  1461. XThere are two display modes.  The first, multiline mode, is the default.
  1462. XIt only works if the \fBTERM\fP parameter is set to a valid
  1463. Xterminal type that can move the cursor up.  The second,
  1464. Xsingle line mode, is used if \fBTERM\fP is invalid or incapable
  1465. Xof moving the cursor up, or if the \fBSINGLE_LINE_ZLE\fP
  1466. Xoption is set.  This mode is similar to ksh, and uses no
  1467. Xtermcap sequences.
  1468. X.SS Bindings
  1469. XCommand bindings may be set using the \fBbindkey\fP builtin.
  1470. XThere are two keymaps\-the main keymap and the alternate keymap.
  1471. XThe alternate keymap is bound to vi command mode.
  1472. XThe main keymap is bound to emacs mode by default.
  1473. XTo bind the main keymap to vi insert mode, use 
  1474. X\fBbindkey \-v\fP, or set one of the \fBVISUAL\fP or \fBEDITOR\fP
  1475. Xenvironment variables to a string containing \fBvi\fP.
  1476. X.PP
  1477. XThe following is a list of all the key commands
  1478. Xand their default bindings in emacs and vi command mode.
  1479. X.SS Movement
  1480. X.TP
  1481. X\fBvi-backward-blank-word\fP (unbound) (B)
  1482. XMove backward one word, where a word is defined as a series of
  1483. Xnon-blank characters.
  1484. X.TP
  1485. X\fBbackward-char\fP (^B ESC-[D) (\|)
  1486. XMove backward one character.
  1487. X.TP
  1488. X\fBvi-backward-char\fP (\|) (h)
  1489. XMove backward one character, without changing lines.
  1490. X.TP
  1491. X\fBbackward-word\fP (ESC-B ESC-b) (b)
  1492. XMove to the beginning of the previous word.
  1493. X.TP
  1494. X\fBbeginning-of-line\fP (^A) (0)
  1495. XMove to the beginning of the line.  If already at the beginning
  1496. Xof the line, move to the beginning of the previous line, if any.
  1497. X.TP
  1498. X\fBvi-beginning-of-line\fP
  1499. XMove to the beginning of the line, without changing lines.
  1500. X.TP
  1501. X\fBemacs-backward-word\fP
  1502. XMove to the beginning of the previous word.
  1503. X.TP
  1504. X\fBemacs-forward-word\fP
  1505. XMove to the end of the next word.
  1506. X.TP
  1507. X\fBend-of-line\fP (^E)
  1508. XMove to the end of the line.  If already at the end 
  1509. Xof the line, move to the end of the next line, if any.
  1510. X.TP
  1511. X\fBvi-end-of-line\fP (unbound) ($)
  1512. XMove to the end of the line.
  1513. X.TP
  1514. X\fBvi-forward-blank-word\fP (unbound) (W)
  1515. XMove forward one word, where a word is defined as a series of
  1516. Xnon-blank characters.
  1517. X.TP
  1518. X\fBvi-forward-blank-word-end\fP (unbound) (E)
  1519. XMove to the end of the current word,
  1520. Xor, if at the end of the current word,
  1521. Xto the end of the next word,
  1522. Xwhere a word is defined as a series of
  1523. Xnon-blank characters.
  1524. X.TP
  1525. X\fBforward-char\fP (^F ESC-[C)
  1526. XMove forward one character.
  1527. X.TP
  1528. X\fBvi-forward-char\fP (unbound) (space l)
  1529. XMove forward one character.
  1530. X.TP
  1531. X\fBforward-word\fP (ESC-F ESC-f) (w)
  1532. XMove to the beginning of the next word.
  1533. XThe editor's idea of a word is specified with the \fBWORDCHARS\fP
  1534. Xparameter.
  1535. X.TP
  1536. X\fBvi-find-next-char\fP (^X^F) (f)
  1537. XRead a character from the keyboard, and move to
  1538. Xthe next occurrence of it in the line.
  1539. X.TP
  1540. X\fBvi-find-next-char-skip\fP (unbound) (t)
  1541. XRead a character from the keyboard, and move to
  1542. Xthe position just before the next occurrence of it in the line.
  1543. X.TP
  1544. X\fBvi-find-prev-char\fP (unbound) (F)
  1545. XRead a character from the keyboard, and move to
  1546. Xthe previous occurrence of it in the line.
  1547. X.TP
  1548. X\fBvi-find-prev-char-skip\fP (unbound) (T)
  1549. XRead a character from the keyboard, and move to
  1550. Xthe position just after the previous occurrence of it in the line.
  1551. X.TP
  1552. X\fBvi-first-non-blank\fP (unbound) (^)
  1553. XMove to the first non-blank character in the line.
  1554. X.TP
  1555. X\fBvi-forward-word-end\fP (unbound) (e)
  1556. XMove to the end of the next word.
  1557. X.TP
  1558. X\fBvi-goto-column\fP (ESC-|) (|)
  1559. XMove to the column specified by the numeric argument.
  1560. X.TP
  1561. X\fBvi-goto-mark\fP (unbound) (`)
  1562. XMove to the specified mark.
  1563. X.TP
  1564. X\fBvi-goto-mark-line\fP (unbound) (')
  1565. XMove to beginning of the line containing the specified mark.
  1566. X.TP
  1567. X\fBvi-repeat-find\fP (unbound) (;)
  1568. XRepeat the last \fBvi-find\fP command.
  1569. X.TP
  1570. X\fBvi-rev-repeat-find\fP (unbound) (,)
  1571. XRepeat the last \fBvi-find\fP command in the opposite direction.
  1572. X.SS History
  1573. X.TP
  1574. X\fBbeginning-of-buffer-or-history\fP (ESC-<)
  1575. XMove to the beginning of the buffer, or if already there,
  1576. Xmove to the first event in the history list.
  1577. X.TP
  1578. X\fBbeginning-of-line-hist\fP
  1579. XMove to the beginning of the line.  If already at the
  1580. Xbeginning of the buffer, move to the previous history line.
  1581. X.TP
  1582. X\fBbeginning-of-history\fP
  1583. XMove to the first event in the history list.
  1584. X.TP
  1585. X\fBdown-line-or-history\fP (^N ESC-[B) (+ j)
  1586. XMove down a line in the buffer, or if already at the bottom line,
  1587. Xmove to the next event in the history list.
  1588. X.TP
  1589. X\fBdown-history\fP (unbound) (^N)
  1590. XMove to the next event in the history list.
  1591. X.TP
  1592. X\fBend-of-buffer-or-history\fP (ESC->)
  1593. XMove to the end of the buffer, or if already there,
  1594. Xmove to the last event in the history list.
  1595. X.TP
  1596. X\fBend-of-line-hist\fP
  1597. XMove to the end of the line.  If already at the end of
  1598. Xthe buffer, move to the next history line.
  1599. X.TP
  1600. X\fBend-of-history\fP
  1601. XMove to the last event in the history list.
  1602. X.TP
  1603. X\fBvi-fetch-history\fP (unbound) (G)
  1604. XFetch the history line specified by the numeric argument.
  1605. X.TP
  1606. X\fBhistory-incremental-search-backward\fP (^R ^XR)
  1607. XSearch backward incrementally for a specified string.
  1608. XThe string may begin with `^' to anchor the search to the
  1609. Xbeginning of the line.
  1610. X.TP
  1611. X\fBhistory-incremental-search-forward\fP (^XS)
  1612. XSearch forward incrementally for a specified string.
  1613. XThe string may begin with `^' to anchor the search to the
  1614. Xbeginning of the line.
  1615. X.TP
  1616. X\fBhistory-search-backward\fP (ESC-P ESC-p) (K)
  1617. XSearch backward in the history for a line beginning with the first
  1618. Xword in the buffer.
  1619. X.TP
  1620. X\fBvi-history-search-backward\fP (unbound) (/)
  1621. XSearch backward in the history for a specified string.
  1622. XThe string may begin with `^' to anchor the search to the
  1623. Xbeginning of the line.
  1624. X.TP
  1625. X\fBhistory-search-forward\fP (ESC-N ESC-n) (J)
  1626. XSearch forward in the history for a line beginning with the first
  1627. Xword in the buffer.
  1628. X.TP
  1629. X\fBvi-history-search-forward\fP (unbound) (?)
  1630. XSearch forward in the history for a specified string.
  1631. XThe string may begin with `^' to anchor the search to the
  1632. Xbeginning of the line.
  1633. X.TP
  1634. X\fBinfer-next-history\fP (^X^N)
  1635. XSearch in the history list for a line matching the current one and
  1636. Xfetch the event following it.
  1637. X.TP
  1638. X\fBinsert-last-word\fP (ESC-_ ESC-.)
  1639. XInsert the last word from the previous history event at the
  1640. Xcursor position.
  1641. X.TP
  1642. X\fBvi-repeat-search\fP (unbound) (n)
  1643. XRepeat the last vi history search.
  1644. X.TP
  1645. X\fBvi-rev-repeat-search\fP (unbound) (N)
  1646. XRepeat the last vi history search, but in reverse.
  1647. X.TP
  1648. X\fBtoggle-literal-history\fP (ESC-R ESC-r)
  1649. XToggle between literal and lexical history.  The default is
  1650. Xlexical history unless the \fBHISTLIT\fP option is set.
  1651. X.TP
  1652. X\fBup-line-or-history\fP (^P ESC-[A) (- k)
  1653. XMove up a line in the buffer, or if already at the top line,
  1654. Xmove to the previous event in the history list.
  1655. X.TP
  1656. X\fBup-history\fP (unbound) (^P)
  1657. XMove to the previous event in the history list.
  1658. X.SS Modifying Text
  1659. X.TP
  1660. X\fBvi-add-eol\fP (unbound) (A)
  1661. XMove to the end of the line and enter insert mode.
  1662. X.TP
  1663. X\fBvi-add-next\fP (unbound) (a)
  1664. XMove forward one character and enter insert mode.
  1665. X.TP
  1666. X\fBbackward-delete-char\fP (^H ^?) (^?)
  1667. XDelete the character behind the cursor.
  1668. X.TP
  1669. X\fBvi-backward-delete-char\fP (unbound) (X)
  1670. XDelete the character behind the cursor, without changing lines.
  1671. X.TP
  1672. X\fBbackward-delete-word\fP
  1673. XDelete the word behind the cursor.
  1674. X.TP
  1675. X\fBbackward-kill-line\fP
  1676. XKill from the beginning of the line to the cursor position.
  1677. X.TP
  1678. X\fBbackward-kill-word\fP (^W ESC-^H ESC-^?)
  1679. XKill the word behind the cursor.
  1680. X.TP
  1681. X\fBvi-backward-kill-word\fP (unbound) (^W)
  1682. XKill the word behind the cursor.
  1683. X.TP
  1684. X\fBcapitalize-word\fP (ESC-C ESC-c)
  1685. XCapitalize the current word and move past it.
  1686. X.TP
  1687. X\fBvi-change\fP (unbound) (c)
  1688. XRead a movement command from the keyboard, and kill
  1689. Xfrom the cursor position to the endpoint of the movement.
  1690. XThen enter insert mode.
  1691. XIf the command is \fBvi-change\fP, kill the current line.
  1692. X.TP
  1693. X\fBvi-change-eol\fP (unbound) (C)
  1694. XKill to the end of the line and enter insert mode.
  1695. X.TP
  1696. X\fBvi-change-whole-line\fP (unbound) (S s)
  1697. XKill the current line and enter insert mode.
  1698. X.TP
  1699. X\fBcopy-region-as-kill\fP (ESC-W ESC-w)
  1700. XCopy the area from the cursor to the mark to the kill buffer.
  1701. X.TP
  1702. X\fBcopy-prev-word\fP (ESC-^_)
  1703. XDuplicate the word behind the cursor.
  1704. X.TP
  1705. X\fBvi-delete\fP (unbound) (d)
  1706. XRead a movement command from the keyboard, and kill 
  1707. Xfrom the cursor position to the endpoint of the movement.
  1708. XIf the command is \fBvi-delete\fP, kill the current line.
  1709. X.TP
  1710. X\fBdelete-char\fP (unbound) (x)
  1711. XDelete the character under the cursor.
  1712. X.TP
  1713. X\fBvi-delete-char\fP (unbound) (x)
  1714. XDelete the character under the cursor.
  1715. X.TP
  1716. X\fBdelete-word\fP (ESC-D ESC-d)
  1717. XDelete the current word.
  1718. X.TP
  1719. X\fBdown-case-word\fP (ESC-L ESC-l)
  1720. XConvert the current word to all lowercase and move past it.
  1721. X.TP
  1722. X\fBkill-word\fP
  1723. XKill the current word.
  1724. X.TP
  1725. X\fBgosmacs-transpose-chars\fP
  1726. XExchange the two characters behind the cursor.
  1727. X.TP
  1728. X\fBvi-indent\fP (unbound) (>)
  1729. XIndent a number of lines.
  1730. X.TP
  1731. X\fBvi-insert\fP (unbound) (i)
  1732. XEnter insert mode.
  1733. X.TP
  1734. X\fBvi-insert-bol\fP (unbound) (I)
  1735. XMove to the beginning of the line and enter insert mode.\fP
  1736. X.TP
  1737. X\fBvi-join\fP (^X^J)
  1738. XJoin the current line with the next one.
  1739. X.TP
  1740. X\fBkill-line\fP (^K) (D)
  1741. XKill from the cursor to the end of the line.
  1742. X.TP
  1743. X\fBkill-region\fP
  1744. XKill from the cursor to the mark.
  1745. X.TP
  1746. X\fBkill-buffer\fP (^X^U) (^U)
  1747. XKill the entire buffer.
  1748. X.TP
  1749. X\fBkill-whole-line\fP (^U) (unbound)
  1750. XKill the current line.
  1751. X.TP
  1752. X\fBvi-match-bracket\fP (^X^B) (%)
  1753. XMove to the bracket character (one of {\|}, (\|), or [\|]) that
  1754. Xmatches the one under the cursor.
  1755. X.TP
  1756. X\fBvi-open-line-above\fP (unbound) (O)
  1757. XOpen a line above the cursor and enter insert mode.
  1758. X.TP
  1759. X\fBvi-open-line-below\fP (unbound) (o)
  1760. XOpen a line below the cursor and enter insert mode.
  1761. X.TP
  1762. X\fBvi-oper-swap-case\fP
  1763. XRead a movement command from the keyboard, and swap
  1764. Xthe case of all characters
  1765. Xfrom the cursor position to the endpoint of the movement.
  1766. XIf the movement command is \fBvi-oper-swap-case\fP,
  1767. Xswap the case of all characters on the current line.
  1768. X.TP
  1769. X\fBoverwrite-mode\fP (^X^O)
  1770. XToggle between overwrite mode and insert mode.
  1771. X.TP
  1772. X\fBvi-put-after\fP (unbound) (p)
  1773. XInsert the contents of the kill buffer after the cursor.
  1774. X.TP
  1775. X\fBquoted-insert\fP (^V)
  1776. XInsert the next character typed into the buffer literally.
  1777. X.TP
  1778. X\fBquote-line\fP (ESC-')
  1779. XQuote the current line; that is, put a ' character at the
  1780. Xbeginning and the end, and convert all ' characters
  1781. Xto '\e''.
  1782. X.TP
  1783. X\fBquote-region\fP (ESC-")
  1784. XQuote the region from the cursor to the mark.
  1785. X.TP
  1786. X\fBvi-replace\fP (unbound) (R)
  1787. XEnter overwrite mode.
  1788. X.TP
  1789. X\fBvi-repeat-change\fP (unbound) (.)
  1790. XRepeat the last vi mode text modification.
  1791. X.TP
  1792. X\fBvi-replace-chars\fP (unbound) (r)
  1793. XReplace the character under the cursor with a character
  1794. Xread from the keyboard.
  1795. X.TP
  1796. X\fBself-insert\fP (printable characters)
  1797. XPut a character in the buffer at the cursor position.
  1798. X.TP
  1799. X\fBself-insert-unmeta\fP (ESC-^I ESC-^J ESC-^M)
  1800. XPut a character in the buffer after stripping the meta bit
  1801. Xand converting \fB^M\fP to \fB^J\fP.
  1802. X.TP
  1803. X\fBvi-substitute\fP (unbound) (s)
  1804. XSubstitute the next character(s).
  1805. X.TP
  1806. X\fBvi-swap-case\fP (unbound) (~)
  1807. XSwap the case of the character under the cursor and move past it.
  1808. X.TP
  1809. X\fBtranspose-chars\fP (^T)
  1810. XExchange the two characters to the left of the
  1811. Xcursor if at end of line, else exchange the
  1812. Xcharacter under the cursor with the character
  1813. Xto the left.
  1814. X.TP
  1815. X\fBtranspose-words\fP (ESC-T ESC-t)
  1816. XExchange the current word with the one before it.
  1817. X.TP
  1818. X\fBvi-unindent\fP (unbound) (<)
  1819. XUnindent a number of lines.
  1820. X.TP
  1821. X\fBup-case-word\fP (ESC-U ESC-u)
  1822. XConvert the current word to all caps and move past it.
  1823. X.TP
  1824. X\fByank\fP (^Y) (P)
  1825. XInsert the contents of the kill buffer at the cursor position.
  1826. X.TP
  1827. X\fByank-pop\fP (ESC-y) (unbound)
  1828. XRemove the text just yanked, rotate the kill\-ring,
  1829. Xand yank the new top.  Only works following
  1830. X\fByank\fP or \fByank-pop\fP.
  1831. X.TP
  1832. X\fBvi-yank\fP (unbound) (y)
  1833. XRead a movement command from the keyboard, and copy the region
  1834. Xfrom the cursor position to the endpoint of the movement
  1835. Xinto the kill buffer.
  1836. XIf the command is \fBvi-yank\fP, copy the current line.
  1837. X.TP
  1838. X\fBvi-yank-eol\fP (unbound) (Y)
  1839. XCopy the region from the cursor position to the end of the line
  1840. Xinto the kill buffer.
  1841. X.SS Arguments
  1842. X.TP
  1843. X\fBdigit-argument\fP (ESC-0..ESC-9) (0-9)
  1844. XStart a new numeric argument, or add to the current one.
  1845. SHAR_EOF
  1846. true || echo 'restore of zsh2.1/man/man1/zsh.1 failed'
  1847. fi
  1848. echo 'End of zsh2.1.0 part 2'
  1849. echo 'File zsh2.1/man/man1/zsh.1 is continued in part 3'
  1850. echo 3 > _shar_seq_.tmp
  1851. exit 0
  1852.  
  1853. exit 0 # Just in case...
  1854. -- 
  1855. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1856. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1857. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1858. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1859.