home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Shells / zsh-3.0.5-MIHS / docs / zsh.info-1 < prev    next >
Encoding:
GNU Info File  |  1997-06-23  |  47.9 KB  |  1,448 lines

  1. This is Info file zsh.info, produced by Makeinfo-1.64 from the input
  2. file ../../zsh-3.0.4/Doc/zsh.texi.
  3.  
  4. This is a texinfo version of the man page for the Z Shell, originally by
  5. Paul Falstad.  It was converted from the `zsh.1' file distributed with
  6. zsh v2.5.0 by Jonathan Hardwick, `jch@cs.cmu.edu' and updated/modified
  7. by Clive Messer, `clive@epos.demon.co.uk' to its present state.
  8.  
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided also
  15. that the entire resulting derived work is distributed under the terms
  16. of a permission notice identical to this one.
  17.  
  18.    Permission is granted to copy and distribute translations of this
  19. manual into another language, under the above conditions for modified
  20. versions.
  21.  
  22. 
  23. File: zsh.info,  Node: Top,  Next: The Z Shell Guide,  Prev: (dir),  Up: (dir)
  24.  
  25. The Z Shell Guide
  26. *****************
  27.  
  28. This Info file documents Zsh, a freely available UNIX command
  29. interpreter (shell), which of the standard shells most closely
  30. resembles the Korn shell (ksh), although it is not completely
  31. compatible.
  32.  
  33. Document Edition 2.1.10, last updated 15 October 1996, of `The Z Shell
  34. Guide', for zsh, Version 3.0.1.
  35.  
  36. * Menu:
  37.  
  38. * The Z Shell Guide::
  39. * Introduction::
  40. * Invocation::
  41. * Startup/Shutdown Files::
  42. * Shell Grammar::
  43. * Expansion::
  44. * Redirection::
  45. * Command Execution::
  46. * Functions::
  47. * Jobs & Signals::
  48. * Arithmetic Evaluation::
  49. * Conditional Expressions::
  50. * Compatibility::
  51. * Zsh Line Editor::
  52. * Parameters::
  53. * Options::
  54. * Shell Builtin Commands::
  55. * Programmable Completion::
  56.  
  57.  -- Indices --
  58.  
  59. * Concept Index::
  60. * Variables Index::
  61. * Options Index::
  62. * Functions Index::
  63. * Editor Functions Index::
  64. * Keystroke Index::
  65.  
  66.  -- The Detailed Node Listing --
  67.  
  68. Introduction
  69.  
  70. * Author::
  71. * Availability::
  72. * Undocumented Features::
  73. * Mailing Lists::
  74. * Further Information::
  75.  
  76. Shell Grammar
  77.  
  78. * Simple Commands & Pipelines::
  79. * Precommand Modifiers::
  80. * Complex Commands::
  81. * Alternate Forms For Complex Commands::
  82. * Reserved Words::
  83. * Comments::
  84. * Aliasing::
  85. * Quoting::
  86.  
  87. Expansion
  88.  
  89. * Filename Expansion::
  90. * Process Substitution::
  91. * Parameter Expansion::
  92. * Command Substitution::
  93. * Arithmetic Expansion::
  94. * Brace Expansion::
  95. * Filename Generation::
  96. * History Expansion::
  97.  
  98. Zsh Line Editor
  99.  
  100. * Movement::
  101. * History Control::
  102. * Modifying Text::
  103. * Arguments::
  104. * Completion::
  105. * Miscellaneous::
  106.  
  107. Parameters
  108.  
  109. * Array Parameters::
  110. * Positional Parameters::
  111. * Parameters Set By The Shell::
  112. * Parameters Used By The Shell::
  113.  
  114. Options
  115.  
  116. * Description of Options::
  117. * Single Letter Options::
  118.  
  119. Programmable Completion
  120.  
  121. * Command Flags::
  122. * Options Flags::
  123. * Alternative Completion::
  124. * Extended Completion::
  125. * Example::
  126.  
  127. 
  128. File: zsh.info,  Node: The Z Shell Guide,  Next: Introduction,  Prev: Top,  Up: Top
  129.  
  130. The Z Shell Guide
  131. *****************
  132.  
  133. This document has been produced from the texinfo file `zsh.texi',
  134. included in the `Doc' sub-directory of the Zsh distribution.
  135.  
  136. Origins
  137. =======
  138.  
  139. The texinfo guide was originally put together by Jonathan Hardwick,
  140. `jch@cs.cmu.edu', who converted the `zsh.1' file distributed with zsh
  141. v2.5.0.  After a period of neglect it was updated by Clive Messer,
  142. `clive@epos.demon.co.uk' to reflect the many changes made to both the
  143. shell, the original `zsh.1', (which due to its size and ever increasing
  144. number of options has since been split into several man-pages: `zsh.1',
  145. `zshall.1', `zshbuiltins.1', `zshcompctl.1', `zshcompctl.1',
  146. `zshexpn.1', `zshmisc.1', `zshoptions.1', `zshparam.1', `zshzle.1'),
  147. and also now includes other useful information from the `META-FAQ'.
  148.  
  149. Producing documentation from zsh.texi.
  150. ======================================
  151.  
  152. Whilst this guide for the most part duplicates the man-pages, (suitably
  153. marked-up into texinfo), and is not intended to replace them, it does
  154. offer several advantages over them, not least that the texinfo source
  155. may be converted into several formats, e.g.,
  156.  
  157. The Info guide.
  158.      The Info format allows searching for topics, commands, functions,
  159.      etc.  from the many Indices. The command `makeinfo zsh.texi' is
  160.      used to produce the Info documentation.
  161.  
  162. The printed guide.
  163.      The command `texi2dvi zsh.texi' will output `zsh.dvi' which can
  164.      then be processed with `dvips' and optionally `gs' (Ghostscript) to
  165.      produce a nicely formatted printed guide.
  166.  
  167. The html guide.
  168.      Mark Borges, `mdb@cdc.noaa.gov', maintains an html version of this
  169.      guide at `http://www.mal.com/zsh/Doc/zsh_toc.html'.
  170.      (The html version is produced with `texi2html', which may be
  171.      obtained from `http://wwwcn.cern.ch/dci/texi2html/'. The command
  172.      is, `texi2html -split_chapter -expandinfo zsh.texi')
  173.  
  174. For those who do not have the necessary tools to process texinfo,
  175. precompiled documentation, (PostScript, dvi, info and html formats), is
  176. available from the zsh archive site or its mirrors in the file,
  177. `zsh-doc.tar.gz'. (*Note Availability::, for a list of sites.)
  178.  
  179. Future
  180. ======
  181.  
  182. This guide is actively maintained by Clive Messer,
  183. `clive@epos.demon.co.uk', and Mark Borges, `mdb@cdc.noaa.gov'.
  184. Patches, comments, criticism, and suggestions should be sent to either
  185. of the above or alternatively, the "zsh-workers" mailing list,
  186. `zsh-workers@math.gatech.edu'.
  187.  
  188. 
  189. File: zsh.info,  Node: Introduction,  Next: Invocation,  Prev: The Z Shell Guide,  Up: Top
  190.  
  191. Introduction
  192. ************
  193.  
  194. Zsh is a UNIX command interpreter (shell) usable as an interactive login
  195. shell and as a shell script command processor.  Of the standard shells,
  196. zsh most closely resembles ksh but includes many enhancements.  Zsh has
  197. command line editing, builtin spelling correction, programmable command
  198. completion, shell functions (with autoloading), a history mechanism,
  199. and a host of other features.
  200.  
  201. * Menu:
  202.  
  203. * Author::
  204. * Availability::
  205. * Undocumented Features::
  206. * Mailing Lists::
  207. * Further Information::
  208.  
  209. 
  210. File: zsh.info,  Node: Author,  Next: Availability,  Up: Introduction
  211.  
  212. Author
  213. ======
  214.  
  215. Zsh was originally written by Paul Falstad `pjf@cts.com'.  Zsh is now
  216. maintained by the members of the zsh workers mailing list
  217. `zsh-workers@math.gatech.edu'.  The development is currently
  218. coordinated by Zoltan Hidvegi, `hzoli@cs.elte.hu'.
  219.  
  220. 
  221. File: zsh.info,  Node: Availability,  Next: Undocumented Features,  Prev: Author,  Up: Introduction
  222.  
  223. Availability
  224. ============
  225.  
  226. Zsh is available from the following anonymous ftp sites.  The first is
  227. the official archive site.  The rest are mirror sites which are kept
  228. frequently up to date.  The sites marked with `(G)' may mirror
  229. `ftp.math.gatech.edu' instead of the primary site.
  230.  
  231. Hungary
  232.      `ftp://ftp.cs.elte.hu/pub/zsh/'
  233.      `ftp://ftp.kfki.hu/pub/packages/zsh/'
  234.  
  235. Australia
  236.      `ftp://ftp.ips.oz.au/pub/packages/zsh/'  `(G)'
  237.  
  238. France
  239.      `ftp://ftp.cenatls.cena.dgac.fr/pub/shells/zsh/'
  240.  
  241. Germany
  242.      `ftp://ftp.fu-berlin.de/pub/unix/shells/zsh/'
  243.      `ftp://ftp.gmd.de/packages/zsh/'
  244.      `ftp://ftp.uni-trier.de/pub/unix/shell/zsh/'
  245.  
  246. Japan
  247.      `ftp://ftp.tohoku.ac.jp/mirror/zsh/'
  248.      `ftp://ftp.iij.ad.jp/pub/misc/zsh/'
  249.  
  250. Norway
  251.      `ftp://ftp.uit.no/pub/unix/shells/zsh/'
  252.  
  253. Sweden
  254.      `ftp://ftp.lysator.liu.se/pub/unix/zsh/'
  255.  
  256. UK
  257.      `ftp://ftp.net.lut.ac.uk/zsh/'
  258.  
  259. USA
  260.      `ftp://ftp.math.gatech.edu/pub/zsh/'
  261.      `ftp://uiarchive.uiuc.edu/pub/packages/shells/zsh/'
  262.      `ftp://ftp.sterling.com/zsh/'  `(G)'
  263.      `ftp://ftp.rge.com/pub/shells/zsh/'  `(G)'
  264.  
  265. 
  266. File: zsh.info,  Node: Undocumented Features,  Next: Mailing Lists,  Prev: Availability,  Up: Introduction
  267.  
  268. Undocumented Features
  269. =====================
  270.  
  271. Known only to the recipients of the `zsh-workers' mailing list.
  272. To join the mailing lists, see *Note Mailing Lists::.
  273.  
  274. 
  275. File: zsh.info,  Node: Mailing Lists,  Next: Further Information,  Prev: Undocumented Features,  Up: Introduction
  276.  
  277. Mailing Lists
  278. =============
  279.  
  280. Zsh has 3 mailing lists:
  281.  
  282. `zsh-announce@math.gatech.edu'
  283.      Announcements about releases, major changes in the shell and the
  284.      monthly posting of the Zsh FAQ. (moderated)
  285.  
  286. `zsh-users@math.gatech.edu'
  287.      User discussions.
  288.  
  289. `zsh-workers@math.gatech.edu'
  290.      Hacking, development, bug reports and patches.
  291.  
  292. To subscribe, send mail with the SUBJECT `subscribe <e-mail-address>'
  293. to the associated administrative address for the mailing list.
  294.  
  295. `zsh-announce-request@math.gatech.edu'
  296. `zsh-users-request@math.gatech.edu'
  297. `zsh-workers-request@math.gatech.edu'
  298.  
  299. YOU ONLY NEED TO JOIN ONE OF THE MAILING LISTS AS THEY ARE NESTED.
  300.  
  301. All submissions to `zsh-announce' are automatically forwarded to
  302. `zsh-users'.
  303. All submissions to `zsh-users' are automatically forwarded to
  304. `zsh-workers'.
  305.  
  306. Un-subscribing is done similarly.
  307.  
  308. If you have problems subscribing/unsubscribing to any of the mailing
  309. lists, send mail to Richard Coleman, `coleman@math.gatech.edu'.
  310.  
  311. 
  312. File: zsh.info,  Node: Further Information,  Prev: Mailing Lists,  Up: Introduction
  313.  
  314. Further Information
  315. ===================
  316.  
  317. * Menu:
  318.  
  319. * The Zsh FAQ::
  320. * The Zsh Web Page::
  321. * See Also::
  322.  
  323. 
  324. File: zsh.info,  Node: The Zsh FAQ,  Next: The Zsh Web Page,  Up: Further Information
  325.  
  326. The Zsh FAQ
  327. -----------
  328.  
  329. Zsh has a list of Frequently Asked Questions (FAQ) maintained by Peter
  330. Stephenson, `P.Stephenson@swansea.ac.uk'.  It is regularly posted to
  331. the newsgroup `comp.unix.shell' and the `zsh-announce' mailing list.
  332. The latest version can be found at any of the Zsh ftp sites, or at:
  333. `http://www.mal.com/zsh/FAQ/'
  334.  
  335. 
  336. File: zsh.info,  Node: The Zsh Web Page,  Next: See Also,  Prev: The Zsh FAQ,  Up: Further Information
  337.  
  338. The Zsh Web Page
  339. ----------------
  340.  
  341. Zsh has a web page maintained by Mark Borges, `mdb@cdc.noaa.gov' which
  342. is located at: `http://www.mal.com/zsh/'.
  343.  
  344. 
  345. File: zsh.info,  Node: See Also,  Prev: The Zsh Web Page,  Up: Further Information
  346.  
  347. See Also
  348. --------
  349.  
  350. sh(1), csh(1), tcsh(1), rc(1), bash(1), ksh(1), zshbuiltins(1),
  351. zshcompctl(1), zshexpn(1), zshparam(1), zshzle(1), zshoptions(1),
  352. zshmisc(1)
  353.  
  354. IEEE Standard for information Technology - Portable Operating System
  355. Interface (POSIX) - Part 2: Shell and Utilities, IEEE Inc, 1993, ISBN
  356. 1-55937-255-9.
  357.  
  358. 
  359. File: zsh.info,  Node: Invocation,  Next: Startup/Shutdown Files,  Prev: Introduction,  Up: Top
  360.  
  361. Invocation
  362. **********
  363.  
  364. If the `-s' flag is not present and an argument is given, the first
  365. argument is taken to be the pathname of a script to execute.  The
  366. remaining arguments are assigned to the positional parameters.  The
  367. following flags are interpreted by the shell when invoked:
  368.  
  369. `-c STRING'
  370.      Read commands from STRING.
  371.  
  372. `-i'
  373.      Force shell to be interactive.
  374.  
  375. `-s'
  376.      Read command from the standard input.
  377.  
  378. 
  379. File: zsh.info,  Node: Startup/Shutdown Files,  Next: Shell Grammar,  Prev: Invocation,  Up: Top
  380.  
  381. Startup/Shutdown Files
  382. **********************
  383.  
  384. Commands are first read from `/etc/zshenv'.  If the `RCS' option is
  385. unset within `/etc/zshenv', all other initialization files are skipped.
  386. Otherwise, commands are read from `$ZDOTDIR/.zshenv' (if `ZDOTDIR' is
  387. unset, `HOME' is used instead).  If the first character of argument
  388. zero passed to the shell is `-', or if the `-l' flag is present, then
  389. the shell is assumed to be a login shell, and commands are read from
  390. `/etc/zprofile' and then `$ZDOTDIR/.zprofile'.  Then, if the shell is
  391. interactive and the `NO_RCS' option is unset, commands are read from
  392. `/etc/zshrc' and then `$ZDOTDIR/.zshrc'.  Finally, if the shell is a
  393. login shell, `/etc/zlogin' and `$ZDOTDIR/.zlogin' are read.
  394.  
  395. Files
  396. =====
  397.  
  398. $ZDOTDIR/.zshenv
  399. $ZDOTDIR/.zprofile
  400. $ZDOTDIR/.zshrc
  401. $ZDOTDIR/.zlogin
  402. $ZDOTDIR/.zlogout
  403. ${TMPPREFIX}*  (default is /tmp/zsh*)
  404. /etc/zshenv
  405. /etc/zprofile
  406. /etc/zshrc
  407. /etc/zlogin
  408. /etc/zlogout
  409.  
  410. 
  411. File: zsh.info,  Node: Shell Grammar,  Next: Expansion,  Prev: Startup/Shutdown Files,  Up: Top
  412.  
  413. Shell Grammar
  414. *************
  415.  
  416. * Menu:
  417.  
  418. * Simple Commands & Pipelines::
  419. * Precommand Modifiers::
  420. * Complex Commands::
  421. * Alternate Forms For Complex Commands::
  422. * Reserved Words::
  423. * Comments::
  424. * Aliasing::
  425. * Quoting::
  426.  
  427. 
  428. File: zsh.info,  Node: Simple Commands & Pipelines,  Next: Precommand Modifiers,  Up: Shell Grammar
  429.  
  430. Simple Commands
  431. ===============
  432.  
  433. A "simple command" is a sequence of optional parameter assignments
  434. followed by blank-separated words, with optional redirections
  435. interspersed.  The first word is the command to be executed, and the
  436. remaining words, if any, are arguments to the command.  If a command
  437. name is given, the parameter assignments modify the environment of the
  438. command when it is executed.  The value of a simple command is its exit
  439. status, or 128 plus the signal number if terminated by a signal.
  440.  
  441. A "pipeline" is a sequence of one or more commands separated by `|' or
  442. `|&'.  `|&' is shorthand for `2>&1 |'.  The standard output of each
  443. command is connected to the standard input of the next command in the
  444. pipeline.  If a pipeline is preceded by `coproc', it is executed as a
  445. coprocess; a two-way pipe is established between it and the parent
  446. shell.  The shell can read from or write to the coprocess by means of
  447. the `>&p' and `<&p' redirection operators.  The value of a pipeline is
  448. the value of the last command.  If a pipeline is not preceded by `!',
  449. the value of that pipeline is the logical `NOT' of the value of the
  450. last command.
  451.  
  452. A "sublist" is a sequence of one or more pipelines separated by `&&' or
  453. `||'.  If two pipelines are separated by `&&', the second pipeline is
  454. executed only if the first is successful (returns a zero value).  If
  455. two pipelines are separated by `||', the second is executed only if the
  456. first is unsuccessful (returns a nonzero value).  Both operators have
  457. equal precedence and are left associative.
  458.  
  459. A "list" is a sequence of zero or more sublists separated by, and
  460. optionally terminated by, `;', `&', `&|', `&!', or a newline.  Normally
  461. the shell waits for each list to finish before executing the next one.
  462. If a list is terminated by a `&', `&|', or `&!', the shell executes it
  463. in the background, and does not wait for it to finish.
  464.  
  465. 
  466. File: zsh.info,  Node: Precommand Modifiers,  Next: Complex Commands,  Prev: Simple Commands & Pipelines,  Up: Shell Grammar
  467.  
  468. Precommand Modifiers
  469. ====================
  470.  
  471. A simple command may be preceded by a "precommand" modifier which will
  472. alter how the command is interpreted.  These modifiers are shell builtin
  473. commands with the exception of `nocorrect' which is a reserved word.
  474.  
  475. `-'
  476.      The command is executed with a `-' prepended to its `argv[0]'
  477.      string.
  478.  
  479. `noglob'
  480.      Filename generation (globbing) is not performed on any of the
  481.      words.
  482.  
  483. `nocorrect'
  484.      Spelling correction is not done on any of the words.
  485.  
  486. `exec'
  487.      The command is executed in the parent shell without forking.
  488.  
  489. `command'
  490.      The command word is taken to be the name of an external command,
  491.      rather than a shell function or builtin.
  492.  
  493. 
  494. File: zsh.info,  Node: Complex Commands,  Next: Alternate Forms For Complex Commands,  Prev: Precommand Modifiers,  Up: Shell Grammar
  495.  
  496. Complex Commands
  497. ================
  498.  
  499. A "complex command" in zsh is one of the following:
  500.  
  501. `if LIST then LIST [ elif LIST then LIST ] ... [ else LIST ] fi'
  502.      The `if LIST' is executed, and, if it returns a zero exit status,
  503.      the `then LIST' is executed.  Otherwise, the `elif LIST' is
  504.      executed and, if its value is zero, the `then LIST' is executed.
  505.      If each `elif LIST' returns nonzero, the `else LIST' is executed.
  506.  
  507. `for NAME [ in WORD ... TERM ] do LIST done'
  508.      Where TERM is one or more newline or `;'.  Expand the list of
  509.      WORDs, and set the parameter NAME to each of them in turn,
  510.      executing LIST each time.  If the `in WORD' is omitted, use the
  511.      positional parameters instead of the WORDS.
  512.  
  513. `while LIST do LIST done'
  514.      Execute the `do LIST' as long as the `while LIST' returns a zero
  515.      exit status.
  516.  
  517. `until LIST do LIST done'
  518.      Execute the `do LIST' as long as `until LIST' returns a nonzero
  519.      exit status.
  520.  
  521. `repeat WORD do LIST done'
  522.      WORD is expanded and treated as an arithmetic expression, which
  523.      must evaluate to a number N.  LIST is then executed N times.
  524.  
  525. `case WORD in [ [(] PATTERN [ | PATTERN ] ... ) LIST ;; ] ... esac'
  526.      Execute the LIST associated with the first PATTERN that matches
  527.      WORD, if any.  The form of the patterns is the same as that used
  528.      for filename generation.  *Note Filename Generation::.
  529.  
  530. `select NAME [ in WORD ... TERM ] do LIST done'
  531.      Where TERM is one ore more newline or `;'.  Print the set of
  532.      WORDs, each preceded by a number.  If the `in WORD' is omitted,
  533.      use the positional parameters.  The `PROMPT3' prompt is printed
  534.      and a line is read from standard input.  If this line consists of
  535.      the number of one of the listed WORDs, then the parameter NAME is
  536.      set to the WORD corresponding to this number.  If this line is
  537.      empty, the selection list is printed again.  Otherwise, the value
  538.      of the parameter NAME is set to null.  The contents of the line
  539.      read from standard input is saved in the parameter `REPLY'.  LIST
  540.      is executed for each selection until a break or end-of-file is
  541.      encountered.
  542.  
  543. `( LIST )'
  544.      Execute LIST in a subshell.  Traps set by the `trap' builtin are
  545.      reset to their default values while executing `list'.
  546.  
  547. `{ LIST }'
  548.      Execute LIST.
  549.  
  550. `function WORD ... [ () ] [ TERM ] { LIST }'
  551. `WORD ... () [ TERM ] { LIST }'
  552. `WORD ... () [ TERM ] COMMAND'
  553.      Where TERM is one ore more newline or `;'.  Define a function
  554.      which is referenced by any one of WORD.  Normally, only one WORD
  555.      is provided; multiple WORDs are usually only useful for setting
  556.      traps.  The body of the function is the LIST between the `{' and
  557.      `}'.  *Note Functions::.
  558.  
  559. `time [ PIPELINE ]'
  560.      The PIPELINE is executed, and timing statistics are reported on
  561.      the standard error in the form specified by the `TIMEFMT'
  562.      parameter.  If PIPELINE is omitted, print statistics about the
  563.      shell process and its children.
  564.  
  565. `[[ EXP ]]'
  566.      Evaluates the conditional expression EXP and return a zero exit
  567.      status if it is true.  *Note Conditional Expressions::, for a
  568.      description of EXP.
  569.  
  570. 
  571. File: zsh.info,  Node: Alternate Forms For Complex Commands,  Next: Reserved Words,  Prev: Complex Commands,  Up: Shell Grammar
  572.  
  573. Alternate Forms For Complex Commands
  574. ====================================
  575.  
  576. Many of zsh's complex commands have alternate forms.  These particular
  577. versions of complex commands should be considered deprecated and may be
  578. removed in the future.  The versions in the previous section should be
  579. preferred instead. The short versions below only work if `SUBLIST' is
  580. of the form `{ LIST }' or if the `NO_SHORT_LOOPS' option is not set.
  581.  
  582. `if LIST { LIST } [ elif LIST { LIST } ] ... [ else { LIST } ]'
  583.      An alternate form of `if'.
  584.  
  585. `if LIST SUBLIST'
  586.      A short form of previous one.
  587.  
  588. `for NAME ( WORD ... ) SUBLIST'
  589.      A short form of `for'.
  590.  
  591. `for NAME [ in WORD ... TERM ] SUBLIST'
  592.      Where TERM is one or more newline or `;'.  Another short form of
  593.      `for'.
  594.  
  595. `foreach NAME ( WORD ... ) LIST end'
  596.      Another form of `for'.
  597.  
  598. `while LIST { LIST }'
  599.      An alternative form of `while'.
  600.  
  601. `until LIST { LIST }'
  602.      An alternative form of `until'.
  603.  
  604. `repeat WORD SUBLIST'
  605.      This is a short form of `repeat'.
  606.  
  607. `case WORD { [ [(] PATTERN [ | PATTERN ] ... ) LIST ;; ] ... }'
  608.      An alternative form of `case'.
  609.  
  610. `select NAME [ in WORD TERM ] SUBLIST'
  611.      Where TERM is one or more newline or `;'.  A short form of
  612.      `select'.
  613.  
  614. 
  615. File: zsh.info,  Node: Reserved Words,  Next: Comments,  Prev: Alternate Forms For Complex Commands,  Up: Shell Grammar
  616.  
  617. Reserved Words
  618. ==============
  619.  
  620. The following words are recognized as "reserved words" when used as the
  621. first word of a command unless quoted or disabled using `disable -r':
  622.  
  623. `do' `done' `esac' `then' `elif' `else' `fi' `for' `case' `if' `while'
  624. `function' `repeat' `time' `until' `select' `coproc' `nocorrect'
  625. `foreach' `end' `!' `[[' `{' `}'
  626.  
  627. Additionally `}' is recognized in any position if the `IGNORE_BRACES'
  628. option is not set.
  629.  
  630. 
  631. File: zsh.info,  Node: Comments,  Next: Aliasing,  Prev: Reserved Words,  Up: Shell Grammar
  632.  
  633. Comments
  634. ========
  635.  
  636. In non-interactive shells, or in interactive shells with the
  637. `INTERACTIVE_COMMENTS' option set, a word beginning with the third
  638. character of the `histchars' parameter (`#' by default) causes that
  639. word and all the following characters up to a newline to be ignored.
  640.  
  641. 
  642. File: zsh.info,  Node: Aliasing,  Next: Quoting,  Prev: Comments,  Up: Shell Grammar
  643.  
  644. Aliasing
  645. ========
  646.  
  647. Every token in the shell input is checked to see if there is an alias
  648. defined for it.  If so, it is replaced by the text of the alias if it is
  649. in command position (if it could be the first word of a simple command),
  650. or if the alias is global.  If the text ends with a space, the next word
  651. in the shell input is treated as though it were in command position for
  652. purposes of alias expansion.  An alias is defined using the `alias'
  653. builtin; global aliases may be defined using the `-g' option to that
  654. builtin.
  655.  
  656. Alias substitution is done on the shell input before any other
  657. substitution except history substitution.  Therefore, if an alias is
  658. defined for the word `foo', alias substitution may be avoided by
  659. quoting part of the word, e.g. `\foo'.  But there is nothing to prevent
  660. an alias being defined for `\foo' as well.
  661.  
  662. 
  663. File: zsh.info,  Node: Quoting,  Prev: Aliasing,  Up: Shell Grammar
  664.  
  665. Quoting
  666. =======
  667.  
  668. A character may be "quoted" (that is, made to stand for itself) by
  669. preceding it with a `\'.  `\' followed by a newline is ignored.  All
  670. characters enclosed between a pair of single quotes (`''') are quoted,
  671. except the first character of `histchars' (`!' by default).  A single
  672. quote cannot appear within single quotes.  Inside double quotes (`""'),
  673. parameter and command substitution occurs, and `\' quotes the
  674. characters `\', ``', `"', and `$'.
  675.  
  676. 
  677. File: zsh.info,  Node: Expansion,  Next: Redirection,  Prev: Shell Grammar,  Up: Top
  678.  
  679. Expansion
  680. *********
  681.  
  682. The types of expansions performed are "history expansion", "alias
  683. expansion", "process substitution", "parameter expansion", "command
  684. substitution", "arithmetic expansion", "brace expansion", "filename
  685. expansion", and "filename generation".
  686.  
  687. Expansion is done in the above specified order in five steps.  The
  688. first is "history expansion" which is only performed in interactive
  689. shells.  The next step is "alias expansion" which is done right before
  690. the command line is parsed.  They are followed by "process
  691. substitution", "parameter expansion", "command substitution",
  692. "arithmetic expansion", and "brace expansion" which are performed in
  693. one step in left-to-right fashion.  After these expansions, all
  694. unquoted occurrences of the characters `\', `'', and `"' are removed
  695. and the result is subjected to "filename expansion" followed by
  696. "filename generation".
  697.  
  698. If the `SH_FILE_EXPANSION' option is set, the order of expansion is
  699. modified for compatibility with `sh' and `ksh'.  "Filename expansion" is
  700. performed immediately after "alias substitution", preceding the set of
  701. five substitutions mentioned above.
  702.  
  703. * Menu:
  704.  
  705. * Filename Expansion::
  706. * Process Substitution::
  707. * Parameter Expansion::
  708. * Command Substitution::
  709. * Arithmetic Expansion::
  710. * Brace Expansion::
  711. * Filename Generation::
  712. * History Expansion::
  713.  
  714. 
  715. File: zsh.info,  Node: Filename Expansion,  Next: Process Substitution,  Up: Expansion
  716.  
  717. Filename Expansion
  718. ==================
  719.  
  720. Each word is checked to see if it begins with an unquoted `~'.  If it
  721. does, then the word up to a `/', or the end of the word if there is no
  722. `/', is checked to see if it can be substituted in one of the ways
  723. described here.  If so, then the `~' and the checked portion are
  724. replaced with the appropriate substitute value.
  725.  
  726. A `~' by itself is replaced by the value of the `HOME' parameter.  A
  727. `~' followed by a `+' or a `-' is replaced by the value of `PWD' or
  728. `OLDPWD', respectively.
  729.  
  730. A `~' followed by a number is replaced by the directory at that
  731. position in the directory stack.  `~0' is equivalent to `~+', and `~1'
  732. is the top of the stack.  `~+' followed by a number is replaced by the
  733. directory at that position in the directory stack.  `~+0' is equivalent
  734. to `~+', and `~+1' is the top of the stack.  `~-' followed by a number
  735. is replaced by the directory that many positions from the bottom of the
  736. stack.  `~-0' is the bottom of the stack.  The `PUSHD_MINUS' option
  737. exchanges the effects of `~+' and `~-' where they are followed by a
  738. number.
  739.  
  740. A `~' followed by anything not already covered is looked up as a named
  741. directory, and replaced by the value of that named directory if found.
  742. Named directories are typically home directories for users on the
  743. system.  They may also be defined if the text after the `~' is the name
  744. of a string shell parameter whose value begins with a `/'.  It is also
  745. possible to define directory names using the `-d' option to the `hash'
  746. builtin.
  747.  
  748. In  certain circumstances (in prompts, for instance), when the shell
  749. prints a path, the path is checked to see if it has a named directory
  750. as its prefix.  If so, then the prefix portion is replaced with a `~'
  751. followed by the name of the directory.  The shortest way of referring
  752. to the directory is used, with ties broken in favour of using a named
  753. directory, except when the directory is `/'.
  754.  
  755. If a word begins with an unquoted `=' and the `EQUALS' option is set,
  756. the remainder of the word is taken as the name of a command or alias.
  757. If a command exists by that name, the word is replaced by the full
  758. pathname of the command.  If an alias exists by that name, the word is
  759. replaced with the text of the alias.
  760.  
  761. Filename expansion is performed on the right hand side of a parameter
  762. assignment, including those appearing after commands of the `typeset'
  763. family.  In this case, the right hand side will be treated as a
  764. colon-separated list in the manner of `PATH' so that a `~' or an `='
  765. following a `:' is eligible  for expansion.  All such behavior can be
  766. disabled by quoting the `~', the `=', or the whole expression (but not
  767. simply the colon); the `EQUALS' option is also respected.
  768.  
  769. If the option `MAGIC_EQUAL_SUBST' is set, any unquoted shell argument in
  770. the form `IDENTIFIER=EXPRESSION' becomes eligible for file expansion as
  771. described in the previous  paragraph.  Quoting the first `=' also
  772. inhibits this.
  773.  
  774. 
  775. File: zsh.info,  Node: Process Substitution,  Next: Parameter Expansion,  Prev: Filename Expansion,  Up: Expansion
  776.  
  777. Process Substitution
  778. ====================
  779.  
  780. Each command argument of the form `<(LIST)', `>(LIST)' or `=(LIST)' is
  781. subject to process substitution.  In the case of the `<' and `>' forms,
  782. the shell will run process LIST asynchronously, connected to a named
  783. pipe (FIFO).  The name of this pipe will become the argument to the
  784. command.  If the form with `>' is selected then writing to this file
  785. will provide input for LIST.  If `<' is used, then the file passed as
  786. an argument will be a named pipe connected to the output of the LIST
  787. process.  For example,
  788.  
  789.    `paste <(cut -f1 FILE1) <(cut -f3 FILE2) | tee >(PROCESS1)
  790. >(PROCESS2) >/dev/null'
  791.  
  792. `cut's fields 1 and 3 from the files FILE1 and FILE2 respectively,
  793. `paste's the results together, and sends it to the processes PROCESS1
  794. and PROCESS2.  Note that the file, which is passed as an argument to
  795. the command, is a system pipe so programs that expect to `lseek(2)' on
  796. the file will not work.  Also note that the previous example can be
  797. more compactly and efficiently written as:
  798.  
  799.    `paste <(cut -f1 FILE1) <(cut -f3 FILE2) >>(PROCESS1) >>(PROCESS2)'
  800.  
  801. The shell uses pipes instead of FIFOs to implement the latter two
  802. process substitutions in the above example.
  803.  
  804. If `=' is used, then the file passed as an argument will be the name of
  805. a temporary file containing the output of the LIST process.  This may
  806. be used instead of the `<' form for a program that expects to
  807. `lseek(2)' on the input file.
  808.  
  809. 
  810. File: zsh.info,  Node: Parameter Expansion,  Next: Command Substitution,  Prev: Process Substitution,  Up: Expansion
  811.  
  812. Parameter Expansion
  813. ===================
  814.  
  815. The character `$' is used to introduce parameter expansions.  *Note
  816. Parameters::, for a description of parameters.  In the expansions
  817. discussed below that require a pattern, the form of the pattern is the
  818. same as that used for filename generation; *Note Filename Generation::.
  819.  
  820. `${NAME}'
  821.      The value, if any, of the parameter NAME is substituted.  The
  822.      braces are required if NAME is followed by a letter, digit, or
  823.      underscore that is not to be interpreted as part of its name.  If
  824.      NAME is an array parameter, then the values of each element of
  825.      NAME is substituted, one element per word.  Otherwise, the
  826.      expansion results in one word only; no word splitting is done on
  827.      the result.
  828.  
  829. `${+NAME}'
  830.      If NAME is the name of a set parameter, `1' is substituted,
  831.      otherwise `0' is substituted.
  832.  
  833. `${NAME:-WORD}'
  834.      If NAME is set and is non-null then substitute its value;
  835.      otherwise substitute WORD. If NAME is missing, substitute WORD.
  836.  
  837. `${NAME:=WORD}'
  838.      If NAME is unset or is null then set it to WORD; the value of the
  839.      parameter is then substituted.
  840.  
  841. `${NAME::=WORD}'
  842.      Set NAME to WORD; the value of the parameter is then substituted.
  843.  
  844. `${NAME:?WORD}'
  845.      If NAME is set and is non-null, then substitute its value;
  846.      otherwise, print WORD and exit from the shell.  If WORD is
  847.      omitted, then a standard message is printed.
  848.  
  849. `${NAME:+WORD}'
  850.      If NAME is set and is non-null then substitute WORD; otherwise
  851.      substitute nothing.
  852.  
  853. `${NAME#PATTERN}'
  854. `${NAME##PATTERN}'
  855.      If the PATTERN matches the beginning of the value of NAME, then
  856.      substitute the value of NAME with the matched portion deleted;
  857.      otherwise, just substitute the value of NAME.  In the first form,
  858.      the smallest matching pattern is preferred; in the second form,
  859.      the largest matching pattern is preferred.  If name is an array and
  860.      the substitution is not quoted or the `@' flag or the `NAME[@]'
  861.      syntax is used, matching is performed on each array elements
  862.      separately.
  863.  
  864. `${NAME%PATTERN}'
  865. `${NAME%%PATTERN}'
  866.      If the PATTERN matches the end of the value of NAME, then
  867.      substitute the value of NAME with the matched portion deleted;
  868.      otherwise, just substitute the value of NAME.  In the first form,
  869.      the smallest matching pattern is preferred; in the second form, the
  870.      largest matching pattern is preferred.  If name is an array and
  871.      the substitution is not quoted or the `@' flag or the `NAME[@]'
  872.      syntax is used, matching is performed on each array elements
  873.      separately.
  874.  
  875. `${NAME:#PATTERN}'
  876.      If the pattern matches the value of NAME, then substitute the empty
  877.      string; otherwise, just substitute the value of NAME.  If NAME is
  878.      an array and the substitution is not quoted or the `@' flag or the
  879.      `NAME[@]' syntax is used, matching is performed on each array
  880.      elements separately, and the matched array elements are removed
  881.      (use the `M' flag to remove the non-matched elements).
  882.  
  883. `${#SPEC}'
  884.      If SPEC is one of the above substitutions, substitute the length
  885.      in characters of the result instead of the result itself.  If SPEC
  886.      is an array expression, substitute the number of elements of the
  887.      result.
  888.  
  889. `${^SPEC}'
  890.      Turn on the value of the `RC_EXPAND_PARAM' option for the
  891.      evaluation of SPEC; if the `^' is doubled, turn it off.  When this
  892.      option is set, array expansions of the form `foo${xx}bar', where
  893.      the parameter `xx' is set to `(a b c)', are substituted with
  894.      `fooabar foobbar foocbar' instead of the default `fooa b cbar'.
  895.  
  896. `${=SPEC}'
  897.      Turn on the value of the `SH_WORD_SPLIT' option for the evaluation
  898.      of SPEC; if the `=' is doubled, turn it off.  When this option is
  899.      set, parameter values are split into separate words using `IFS' as
  900.      a delimiter before substitution.  This is done by default in most
  901.      other shells.
  902.  
  903. `${~SPEC}'
  904.      Turn on the value of the `GLOB_SUBST' option for the evaluation of
  905.      SPEC; if the `~' is doubled, turn it off.  When this option is set,
  906.      any pattern characters resulting from the substitution become
  907.      eligible for file expansion and filename generation.
  908.  
  909. If the colon is omitted from one of the above expressions containing a
  910. colon, then the shell only checks whether NAME is set or not, not
  911. whether it is null.
  912.  
  913. If a `${...}' type parameter expression or a `$(...)' type command
  914. substitution is used in place of NAME above, it is substituted first
  915. and the result is used as it were the value of NAME.
  916.  
  917. If the opening brace is directly followed by an opening parenthesis the
  918. string up to the matching closing parenthesis will be taken as a list
  919. of flags.  Where arguments are valid, any character, or the matching
  920. pairs `(...)', `{...}', `[...]', or `<...>', may be used in place of
  921. the colon as delimiters.  The following flags are supported:
  922.  
  923. `A'
  924.      Create an array parameter with `${...:=...}' or `${...::=...}'.
  925.      Assignment is made before sorting or padding.
  926.  
  927. `@'
  928.      In double quotes, array elements are put into separate words. Egfi
  929.      `${(@)FOO}' is equivalent to `${FOO[@]}' and `${(@)FOO[1,2]}' is
  930.      the same as `$FOO[1]' `$FOO[2]'.
  931.  
  932. `e'
  933.      Perform "parameter expansion", "command substitution" and
  934.      "arithmetic expansion" on the result.  Such expansions can be
  935.      nested but too deep recursion may have unpredictable effects.
  936.  
  937. `o'
  938.      Sort the resulting words in ascending order.
  939.  
  940. `O'
  941.      Sort the resulting words in descending order.
  942.  
  943. `i'
  944.      With `o' or `O', makes the sort case-insensitive.
  945.  
  946. `L'
  947.      Converts all letters in the result to lowercase.
  948.  
  949. `U'
  950.      Converts all letters in the result to uppercase.
  951.  
  952. `C'
  953.      Capitalizes the resulting words
  954.  
  955. `c'
  956.      With `${#NAME}', count the total number of characters in an array,
  957.      as if the elements were concatenated with spaces between them.
  958.  
  959. `w'
  960.      With `${#NAME}', count words in arrays or strings; the `s' flag
  961.      may be used to set a word delimiter.
  962.  
  963. `W'
  964.      Similar to `w' with the difference that empty words between
  965.      repeated delimiters are also counted.
  966.  
  967. `p'
  968.      Recognize the same escape sequences as the `print' builtin in
  969.      string arguments to subsequent flags.
  970.  
  971. `l:EXPR::STRING1::STRING2:'
  972.      Pad the resulting words on the left.  Each word will be truncated
  973.      if required and placed in a field EXPR characters wide.  The space
  974.      to the left will be filled with STRING1 (concatenated as often as
  975.      needed), or spaces if STRING1 is not given.  If both STRING1 and
  976.      STRING2 are given, this string will be placed exactly once
  977.      directly to the left of the resulting word.
  978.  
  979. `r:EXPR::STRING1::STRING2:'
  980.      As `l', but pad the words on the right.
  981.  
  982. `j:STRING:'
  983.      Join the words or arrays together using STRING as a separator.
  984.      Note that this occurs before word splitting by the `SH_WORD_SPLIT'
  985.      option.
  986.  
  987. `F'
  988.      Join the words of arrays together using newline as a separator.
  989.      This is a shorthand for `pj:\n:'.
  990.  
  991. `s:STRING:'
  992.      Force word splitting (see the option `SH_WORD_SPLIT') at the
  993.      separator STRING.  Splitting only occurs in places where an array
  994.      value is valid.
  995.  
  996. `f'
  997.      Split the result of the expansion to lines.  This is a shorthand
  998.      for `ps:\n:'.
  999.  
  1000. `S'
  1001.      (This and all remaining flags are used with the `${...#...}' and
  1002.      `${...%...}' forms).  Search substrings as well as beginnings or
  1003.      ends.
  1004.  
  1005. `I:EXPR:'
  1006.      Search the EXPR'th match (where EXPR evaluates to a number).
  1007.  
  1008. `M'
  1009.      Include the matched portion in the result.
  1010.  
  1011. `R'
  1012.      Include the unmatched portion in the result (the Rest).
  1013.  
  1014. `B'
  1015.      Include the index of the beginning of the match in the result.
  1016.  
  1017. `E'
  1018.      Include the index of the end of the match in the result.
  1019.  
  1020. `N'
  1021.      Include the length of the match in the result.
  1022.  
  1023. 
  1024. File: zsh.info,  Node: Command Substitution,  Next: Arithmetic Expansion,  Prev: Parameter Expansion,  Up: Expansion
  1025.  
  1026. Command Substitution
  1027. ====================
  1028.  
  1029. A command enclosed in parentheses preceded by a dollar sign, like so:
  1030. `$(...)' or quoted with grave accents: ``...`' is replaced with its
  1031. standard output, with any trailing newlines deleted.  If the
  1032. substitution is not enclosed in double quotes, the output is broken into
  1033. words using the `IFS' parameter.  The substitution `$(cat FOO)' may be
  1034. replaced by the equivalent but faster `$(<FOO)'.  In either case, if the
  1035. option `GLOB_SUBST' is set the output is eligible for filename
  1036. generation.
  1037.  
  1038. 
  1039. File: zsh.info,  Node: Arithmetic Expansion,  Next: Brace Expansion,  Prev: Command Substitution,  Up: Expansion
  1040.  
  1041. Arithmetic Expansion
  1042. ====================
  1043.  
  1044. A string of the form `$[EXP]' is substituted with the value of the
  1045. arithmetic expression EXP.  EXP is subjected to "parameter expansion",
  1046. "command substitution" and "arithmetic expansion" before it is
  1047. evaluated.  *Note Arithmetic Evaluation::.
  1048.  
  1049. 
  1050. File: zsh.info,  Node: Brace Expansion,  Next: Filename Generation,  Prev: Arithmetic Expansion,  Up: Expansion
  1051.  
  1052. Brace Expansion
  1053. ===============
  1054.  
  1055. A string of the form `foo{xx,yy,zz}bar' is expanded to the individual
  1056. words `fooxxbar', `fooyybar', and `foozzbar'.  Left-to-right order is
  1057. preserved.  This construct may be nested.  Commas may be quoted in
  1058. order to include them literally in a word.
  1059.  
  1060. An expression of the form `{N1..N2}', where N1 and N2 are integers, is
  1061. expanded to every number between N1 and N2, inclusive.  If either
  1062. number begins with a zero, all the resulting numbers will be padded
  1063. with leading zeroes to that minimum width.  If the numbers are in
  1064. decreasing order the resulting sequence will also be in decreasing
  1065. order.
  1066.  
  1067. If a brace expression matches none of the above forms, it is left
  1068. unchanged, unless the `BRACE_CCL' option is set.  In that case, it is
  1069. expanded to a sorted list of the individual characters between the
  1070. braces, in the manner of a search set.  `-' is treated specially as in
  1071. a search set, but `^' or `!' as the first character is treated normally.
  1072.  
  1073. 
  1074. File: zsh.info,  Node: Filename Generation,  Next: History Expansion,  Prev: Brace Expansion,  Up: Expansion
  1075.  
  1076. Filename Generation
  1077. ===================
  1078.  
  1079. If a word contains an unquoted instance of one of the characters `*',
  1080. `|', `<', `[', or `?', it is regarded as a pattern for filename
  1081. generation, unless the `GLOB' option is unset.  If the `EXTENDED_GLOB'
  1082. option is set, the `^', `~', and `#' characters also denote a pattern;
  1083. otherwise (except for an initial `~', *Note Filename Expansion::) they
  1084. are not treated specially by the shell.  The word is replaced with a
  1085. list of sorted filenames that match the pattern.  If no matching
  1086. pattern is found, the shell gives an error message, unless the
  1087. `NULL_GLOB' option is set, in which case the word is deleted; or unless
  1088. the `NOMATCH' option is unset, in which case the word is left
  1089. unchanged.  In filename generation, the character `/' must be matched
  1090. explicitly; also, a `.' must be matched explicitly at the beginning of
  1091. a pattern or after a `/', unless the `GLOB_DOTS' option is set.  No
  1092. filename generation pattern matches the files `.' or `..'.  In other
  1093. instances of pattern matching, the `/' and `.' are not treated
  1094. specially.
  1095.  
  1096. `*'
  1097.      Matches any string, including the null string.
  1098.  
  1099. `?'
  1100.      Matches any character.
  1101.  
  1102. `[...]'
  1103.      Matches any of the enclosed characters. Ranges of characters can
  1104.      be specified by separating two characters by a `-'.  A `-' or `]'
  1105.      may be matched by including it as the first character in the list.
  1106.  
  1107. `[^...]'
  1108. `[!...]'
  1109.      Like `[...]', except that it matches any character which is not in
  1110.      the given set.
  1111.  
  1112. `<x-y>'
  1113.      Matches any number in the range `x' to `y', inclusive.  If `x' is
  1114.      omitted, the number must be less than or equal to `y'.  If `y' is
  1115.      omitted, the number must be greater than or equal to `x'.  A
  1116.      pattern of the form `<->' matches any number.
  1117.  
  1118. `^x'
  1119.      Matches anything except the pattern `x'.
  1120.  
  1121. `x|y'
  1122.      Matches either `x' or `y'.
  1123.  
  1124. `x#'
  1125.      Matches zero or more occurrences of the pattern `x'.
  1126.  
  1127. `x##'
  1128.      Matches one or more occurrences of the pattern `x'.
  1129.  
  1130. Parentheses may be used for grouping.  Note that the `|' character must
  1131. be within parentheses, so that the lexical analyzer does not think it
  1132. is a pipe character.  Also note that `/' has a higher precedence than
  1133. `^'; that is:
  1134.  
  1135.    `ls ^foo/bar'
  1136.  
  1137. will search directories in `.' except `./foo' for a file named `bar'.
  1138.  
  1139. A pathname component of the form `(FOO/)#' matches a path consisting of
  1140. zero or more directories matching the pattern FOO.  As a shorthand,
  1141. `**/' is equivalent to `(*/)#'.  Thus:
  1142.  
  1143.    `ls (*/)#BAR'
  1144.  
  1145. or
  1146.  
  1147.    `ls **/BAR'
  1148.  
  1149. does a recursive directory search for files named BAR, not following
  1150. symbolic links.  For this you can use the form `***/'.
  1151.  
  1152. If used for filename generation, a pattern may contain an exclusion
  1153. specifier.  Such patterns are of the form `PAT1~PAT2'.  This pattern
  1154. will generate all files matching PAT1, but which do not match PAT2.
  1155. For example, `*.c~lex.c' will match all files ending in `.c', except
  1156. the file `lex.c'.  This may appear inside parentheses.  Note that `~'
  1157. has higher precedence than `|', so that `pat1|pat2~pat3' matches any
  1158. time that PAT1 matches, or if PAT2 matches while PAT3 does not.  Note
  1159. also that any `/' characters are not treated specially in the exclusion
  1160. specifier, so that a `*' will match multiple path segments if they
  1161. appear in the pattern to the left of the `~'.
  1162.  
  1163. Patterns used for filename generation may also end in a list of
  1164. qualifiers enclosed in parentheses.  The qualifiers specify which
  1165. filenames that otherwise match the given pattern will be inserted in the
  1166. argument list.  A qualifier may be any one of the following:
  1167.  
  1168. `/'
  1169.      Directories
  1170.  
  1171. `.'
  1172.      Plain files
  1173.  
  1174. `@'
  1175.      Symbolic links
  1176.  
  1177. `='
  1178.      Sockets
  1179.  
  1180. `p'
  1181.      Named pipes (FIFOs)
  1182.  
  1183. `*'
  1184.      Executable plain files (0100)
  1185.  
  1186. `%'
  1187.      Device files (character or block special)
  1188.  
  1189. `%b'
  1190.      Block special files
  1191.  
  1192. `%c'
  1193.      Character special files
  1194.  
  1195. `r'
  1196.      owner-readable files (0400)
  1197.  
  1198. `w'
  1199.      owner-writable files (0200)
  1200.  
  1201. `x'
  1202.      owner-executable files (0100)
  1203.  
  1204. `A'
  1205.      group-readable files (0040)
  1206.  
  1207. `I'
  1208.      group-writable files (0020)
  1209.  
  1210. `E'
  1211.      group-executable files (0010)
  1212.  
  1213. `R'
  1214.      world-readable files (0004)
  1215.  
  1216. `W'
  1217.      world-writable files (0002)
  1218.  
  1219. `X'
  1220.      world-executable files (0001)
  1221.  
  1222. `s'
  1223.      Setuid files (04000)
  1224.  
  1225. `S'
  1226.      Setgid files (02000)
  1227.  
  1228. `t'
  1229.      files with the sticky bit (01000)
  1230.  
  1231. `dDEV'
  1232.      Files on the device DEV
  1233.  
  1234. `l[+|-]CT'
  1235.      Files having a link count less than `CT (-)', greater than `CT
  1236.      (+)', or is equal to `CT'.
  1237.  
  1238. `U'
  1239.      Files owned by the effective user id.
  1240.  
  1241. `G'
  1242.      Files owned by the effective group id.
  1243.  
  1244. `uID'
  1245.      Files owned by user ID if ID is a number.  If not, the character
  1246.      after the `u' will be used as a separator and the string between
  1247.      it and the next matching separator (`(', `[', `{', and `<' match
  1248.      `)', `]', `}', and `>' respectively; any other character matches
  1249.      itself) will be taken as a user name and translated into the
  1250.      corresponding user id (e.g.  `u:foo:' or `u[foo]' for user `foo').
  1251.  
  1252. `gID'
  1253.      Like `uID' but with group ids or names.
  1254.  
  1255. `a[Mwhm][-|+]N'
  1256.      Files accessed exactly N days ago.  Files accessed within the last
  1257.      N days are selected using a negative value for N (`-n').  Files
  1258.      accessed more than N days ago are selected by a positive N value
  1259.      (`+n').  Optional unit specifiers `M', `w', `h', or `m' (e.g.
  1260.      `ah5') cause the check to be performed with months (of 30 days),
  1261.      weeks, hours, or minutes instead of days, respectively.  For
  1262.      instance, `echo *(ah-5)' would echo files accessed within the last
  1263.      five hours.
  1264.  
  1265. `m[Mwhm][-|+]N'
  1266.      Like the file access qualifier, except that it uses the file
  1267.      modification time.
  1268.  
  1269. `c[Mwhm][-|+]N'
  1270.      Like the file access qualifier, except that it uses the file inode
  1271.      change time.
  1272.  
  1273. `L[+-]N'
  1274.      Files less than N bytes (`-'), more than N bytes (`+'), or exactly
  1275.      N bytes in length.  If this flag is directly followed by a `k'
  1276.      (`K'), `m' (`M'), or `p' (`P') (e.g. `Lk+50') the check is
  1277.      performed with kilobytes, megabytes, or blocks (of 512 bytes)
  1278.      instead.
  1279.  
  1280. `^'
  1281.      Negates all qualifiers following it.
  1282.  
  1283. `-'
  1284.      Toggles between making the qualifiers work on symbolic links (the
  1285.      default), and the files they point to.
  1286.  
  1287. `M'
  1288.      Sets the `MARK_DIRS' option for the current pattern.
  1289.  
  1290. `T'
  1291.      Appends a trailing qualifier mark to the file names, analogous to
  1292.      the `LIST_TYPES', for the current pattern (overrides `M').
  1293.  
  1294. `N'
  1295.      Sets the `NULL_GLOB' option for the current pattern.
  1296.  
  1297. `D'
  1298.      Sets the `GLOB_DOTS' option for the current pattern.
  1299.  
  1300. More than one of these lists can be combined, separated by commas; the
  1301. whole list matches if at least one of the sublists matches (they are
  1302. `or''ed, the qualifiers in the sublists are `and''ed).
  1303.  
  1304. If a `:' appears in a qualifier list, the remainder of the expression
  1305. in parentheses is interpreted as a modifier (*Note Modifiers::).  Note
  1306. that each modifier must be introduced by a separate `:'.  Note also
  1307. that the result after modification does not have to be an existing
  1308. file.  The name of any existing file can be followed by a modifier of
  1309. the form `(:...)' even if no filename generation is performed.
  1310.  
  1311. Thus:
  1312.  
  1313.    `ls *(-/)'
  1314.  
  1315. lists all directories and symbolic links that point to directories, and
  1316.  
  1317.    `ls *(%W)'
  1318.  
  1319. lists all world-writable device files in the current directory, and
  1320.  
  1321.    `ls *(W,X)'
  1322.  
  1323. lists all files in the current directory that are world-writable or
  1324. world-executable, and
  1325.  
  1326.    `echo /tmp/foo*(u0^@:t)'
  1327.  
  1328. outputs the basename of all root-owned files beginning with the string
  1329. `foo' in `/tmp', ignoring symlinks, and
  1330.  
  1331.    `ls *.*~(lex|parse).[ch](^D^l1)'
  1332.  
  1333. lists all files having a link count of one whose names contain a dot
  1334. (but not those starting with a dot, since `GLOB_DOTS' is explicitly
  1335. switched off) except for `lex.c', `lex.h', `parse.c', and `parse.h'.
  1336.  
  1337. 
  1338. File: zsh.info,  Node: History Expansion,  Prev: Filename Generation,  Up: Expansion
  1339.  
  1340. History Expansion
  1341. =================
  1342.  
  1343. History substitution allows you to use words from previous command lines
  1344. in the command line you are typing.  This simplifies spelling
  1345. corrections and the repetition of complicated commands or arguments.
  1346. Command lines are saved in the history list, the size of which is
  1347. controlled by the `HISTSIZE' variable.  The most recent command is
  1348. retained in any case.  A history substitution begins with the first
  1349. character of the `histchars' parameter which is `!' by default and may
  1350. occur anywhere on the command line; history substitutions do not nest.
  1351. The `!' can be escaped with `\' or can be enclosed between a pair of
  1352. single quotes (`''') to suppress its special meaning. Double quotes
  1353. will not work for this.
  1354.  
  1355. Input lines containing history substitutions are echoed on the terminal
  1356. after being expanded, but before any other substitutions take place or
  1357. the command gets executed.
  1358.  
  1359. * Menu:
  1360.  
  1361. * Event Designators::
  1362. * Word Designators::
  1363. * Modifiers::
  1364.  
  1365. 
  1366. File: zsh.info,  Node: Event Designators,  Next: Word Designators,  Up: History Expansion
  1367.  
  1368. Event Designators
  1369. -----------------
  1370.  
  1371. An event designator is a reference to a command-line entry in the
  1372. history list.
  1373.  
  1374. `!'
  1375.      Start a history substitution, except when followed by a blank,
  1376.      newline, `=', or `('.
  1377.  
  1378. `!!'
  1379.      Refer to the previous command.  By itself, this substitution
  1380.      repeats the previous command.
  1381.  
  1382. `!N'
  1383.      Refer to command-line N.
  1384.  
  1385. `!-N'
  1386.      Refer to the current command-line minus N.
  1387.  
  1388. `!STR'
  1389.      Refer to the most recent command starting with STR.
  1390.  
  1391. `!?STR[?]'
  1392.      Refer to the most recent command containing STR.
  1393.  
  1394. `!#'
  1395.      Refer to the current command line typed in so far.  The line is
  1396.      treated as if it were complete up to and including the word before
  1397.      the one with the `!#' reference.
  1398.  
  1399. `!{...}'
  1400.      Insulate a history reference from adjacent characters (if
  1401.      necessary).
  1402.  
  1403. 
  1404. File: zsh.info,  Node: Word Designators,  Next: Modifiers,  Prev: Event Designators,  Up: History Expansion
  1405.  
  1406. Word Designators
  1407. ----------------
  1408.  
  1409. A word designator indicates which word or words of a given command line
  1410. will be included in a history reference.  A `:' separates the event
  1411. specification from the word designator.  It can be omitted if the word
  1412. designator begins with a `^', `$', `*', `-' or `%'.  Word designators
  1413. include:
  1414.  
  1415. `0'
  1416.      The first input word (command).
  1417.  
  1418. `N'
  1419.      The N'th argument.
  1420.  
  1421. `^'
  1422.      The first argument, that is, `1'.
  1423.  
  1424. `$'
  1425.      The last argument.
  1426.  
  1427. `%'
  1428.      The word matched by (the most recent) `?STR' search.
  1429.  
  1430. `x-y'
  1431.      A range of words; `-y' abbreviates `0-y'.
  1432.  
  1433. `*'
  1434.      All the arguments, or a null value if there is just one word in
  1435.      the event.
  1436.  
  1437. `x*'
  1438.      Abbreviates `x-$'.
  1439.  
  1440. `x-'
  1441.      Like `x*' but omitting word `$'.
  1442.  
  1443. Note that a `%' word designator will only work when used as `!%',
  1444. `!:%', `!?str?:%' and only when used after a `!?' substitution.
  1445. Anything else will result in an error, although the error may not be
  1446. the most obvious one.
  1447.  
  1448.