1ZSHMODULES(1)               General Commands Manual              ZSHMODULES(1)
2
3
4

NAME

6       zshmodules - zsh loadable modules
7

DESCRIPTION

9       Some  optional  parts  of zsh are in modules, separate from the core of
10       the shell.  Each of these modules may be linked  in  to  the  shell  at
11       build  time, or can be dynamically linked while the shell is running if
12       the installation supports this feature.  Modules are linked at  runtime
13       with the zmodload command, see zshbuiltins(1).
14
15       The modules that are bundled with the zsh distribution are:
16
17       zsh/attr
18              Builtins for manipulating extended attributes (xattr).
19
20       zsh/cap
21              Builtins  for manipulating POSIX.1e (POSIX.6) capability (privi‐
22              lege) sets.
23
24       zsh/clone
25              A builtin that can clone a running shell onto another terminal.
26
27       zsh/compctl
28              The compctl builtin for controlling completion.
29
30       zsh/complete
31              The basic completion code.
32
33       zsh/complist
34              Completion listing extensions.
35
36       zsh/computil
37              A module with utility builtins needed  for  the  shell  function
38              based completion system.
39
40       zsh/curses
41              curses windowing commands
42
43       zsh/datetime
44              Some date/time commands and parameters.
45
46       zsh/db/gdbm
47              Builtins  for managing associative array parameters tied to GDBM
48              databases.
49
50       zsh/deltochar
51              A ZLE function duplicating EMACS' zap-to-char.
52
53       zsh/example
54              An example of how to write a module.
55
56       zsh/files
57              Some basic file manipulation commands as builtins.
58
59       zsh/langinfo
60              Interface to locale information.
61
62       zsh/mapfile
63              Access to external files via a special associative array.
64
65       zsh/mathfunc
66              Standard scientific functions for use  in  mathematical  evalua‐
67              tions.
68
69       zsh/newuser
70              Arrange for files for new users to be installed.
71
72       zsh/parameter
73              Access to internal hash tables via special associative arrays.
74
75       zsh/pcre
76              Interface to the PCRE library.
77
78       zsh/param/private
79              Builtins for managing private-scoped parameters in function con‐
80              text.
81
82       zsh/regex
83              Interface to the POSIX regex library.
84
85       zsh/sched
86              A builtin that provides a timed execution  facility  within  the
87              shell.
88
89       zsh/net/socket
90              Manipulation of Unix domain sockets
91
92       zsh/stat
93              A builtin command interface to the stat system call.
94
95       zsh/system
96              A builtin interface to various low-level system features.
97
98       zsh/net/tcp
99              Manipulation of TCP sockets
100
101       zsh/termcap
102              Interface to the termcap database.
103
104       zsh/terminfo
105              Interface to the terminfo database.
106
107       zsh/zftp
108              A builtin FTP client.
109
110       zsh/zle
111              The Zsh Line Editor, including the bindkey and vared builtins.
112
113       zsh/zleparameter
114              Access to internals of the Zsh Line Editor via parameters.
115
116       zsh/zprof
117              A module allowing profiling for shell functions.
118
119       zsh/zpty
120              A builtin for starting a command in a pseudo-terminal.
121
122       zsh/zselect
123              Block and return when file descriptors are ready.
124
125       zsh/zutil
126              Some utility builtins, e.g. the one for supporting configuration
127              via styles.
128

THE ZSH/ATTR MODULE

130       The zsh/attr module is used for manipulating extended attributes.   The
131       -h  option  causes all commands to operate on symbolic links instead of
132       their targets.  The builtins in this module are:
133
134       zgetattr [ -h ] filename attribute [ parameter ]
135              Get the extended attribute attribute from  the  specified  file‐
136              name. If the optional argument parameter is given, the attribute
137              is set on that parameter instead of being printed to stdout.
138
139       zsetattr [ -h ] filename attribute value
140              Set the extended attribute attribute on the  specified  filename
141              to value.
142
143       zdelattr [ -h ] filename attribute
144              Remove the extended attribute attribute from the specified file‐
145              name.
146
147       zlistattr [ -h ] filename [ parameter ]
148              List the extended attributes  currently  set  on  the  specified
149              filename.  If the optional argument parameter is given, the list
150              of attributes is set on that parameter instead of being  printed
151              to stdout.
152
153       zgetattr  and  zlistattr allocate memory dynamically.  If the attribute
154       or list of attributes grows between the allocation and the call to  get
155       them,  they return 2.  On all other errors, 1 is returned.  This allows
156       the calling function to check for this case and retry.
157

THE ZSH/CAP MODULE

159       The zsh/cap module is used for manipulating POSIX.1e (POSIX.6) capabil‐
160       ity sets.  If the operating system does not support this interface, the
161       builtins defined by this module will do nothing.  The builtins in  this
162       module are:
163
164       cap [ capabilities ]
165              Change  the  shell's  process  capability  sets to the specified
166              capabilities, otherwise display the  shell's  current  capabili‐
167              ties.
168
169       getcap filename ...
170              This is a built-in implementation of the POSIX standard utility.
171              It displays the capability sets on each specified filename.
172
173       setcap capabilities filename ...
174              This is a built-in implementation of the POSIX standard utility.
175              It  sets  the  capability sets on each specified filename to the
176              specified capabilities.
177

THE ZSH/CLONE MODULE

179       The zsh/clone module makes available one builtin command:
180
181       clone tty
182              Creates a forked instance of the current shell, attached to  the
183              specified  tty.  In the new shell, the PID, PPID and TTY special
184              parameters are changed appropriately.  $! is set to zero in  the
185              new shell, and to the new shell's PID in the original shell.
186
187              The  return status of the builtin is zero in both shells if suc‐
188              cessful, and non-zero on error.
189
190              The target of clone should be an unused  terminal,  such  as  an
191              unused virtual console or a virtual terminal created by
192
193                     xterm -e sh -c 'trap : INT QUIT TSTP; tty;
194                             while :; do sleep 100000000; done'
195
196              Some  words  of  explanation are warranted about this long xterm
197              command line: when doing clone on a pseudo-terminal, some  other
198              session  ("session"  meant  as  a unix session group, or SID) is
199              already owning the terminal. Hence the cloned zsh cannot acquire
200              the pseudo-terminal as a controlling tty. That means two things:
201
202              ·      the    job    control    signals    will    go   to   the
203                     sh-started-by-xterm process group (that's why we  disable
204                     INT  QUIT  and  TSTP  with trap; otherwise the while loop
205                     could get suspended or killed)
206
207              ·      the cloned shell will have job control disabled, and  the
208                     job  control  keys  (control-C,  control-\ and control-Z)
209                     will not work.
210
211              This does not apply when cloning to an unused vc.
212
213              Cloning to a used (and unprepared) terminal will result  in  two
214              processes  reading  simultaneously  from the same terminal, with
215              input bytes going randomly to either process.
216
217              clone is mostly useful  as  a  shell  built-in  replacement  for
218              openvt.
219

THE ZSH/COMPCTL MODULE

221       The  zsh/compctl  module makes available two builtin commands. compctl,
222       is the old, deprecated way to control completions for ZLE.  See zshcom‐
223       pctl(1).    The   other  builtin  command,  compcall  can  be  used  in
224       user-defined completion widgets, see zshcompwid(1).
225

THE ZSH/COMPLETE MODULE

227       The zsh/complete module makes available several builtin commands  which
228       can be used in user-defined completion widgets, see zshcompwid(1).
229

THE ZSH/COMPLIST MODULE

231       The zsh/complist module offers three extensions to completion listings:
232       the ability to highlight matches in such a list, the ability to  scroll
233       through long lists and a different style of menu completion.
234
235   Colored completion listings
236       Whenever one of the parameters ZLS_COLORS or ZLS_COLOURS is set and the
237       zsh/complist module is loaded or  linked  into  the  shell,  completion
238       lists will be colored.  Note, however, that complist will not automati‐
239       cally be loaded if it is not linked in:  on systems with dynamic  load‐
240       ing, `zmodload zsh/complist' is required.
241
242       The  parameters  ZLS_COLORS  and  ZLS_COLOURS  describe how matches are
243       highlighted.  To turn on highlighting an empty value suffices, in which
244       case  all  the  default values given below will be used.  The format of
245       the value of these parameters is the same as used by the GNU version of
246       the  ls  command:  a colon-separated list of specifications of the form
247       `name=value'.  The name may be one of the following  strings,  most  of
248       which specify file types for which the value will be used.  The strings
249       and their default values are:
250
251       no 0   for normal text (i.e. when displaying  something  other  than  a
252              matched file)
253
254       fi 0   for regular files
255
256       di 32  for directories
257
258       ln 36  for  symbolic links.  If this has the special value target, sym‐
259              bolic links are dereferenced and the target file used to  deter‐
260              mine the display format.
261
262       pi 31  for named pipes (FIFOs)
263
264       so 33  for sockets
265
266       bd 44;37
267              for block devices
268
269       cd 44;37
270              for character devices
271
272       or none
273              for  a symlink to nonexistent file (default is the value defined
274              for ln)
275
276       mi none
277              for a non-existent file (default is the value defined  for  fi);
278              this code is currently not used
279
280       su 37;41
281              for files with setuid bit set
282
283       sg 30;43
284              for files with setgid bit set
285
286       tw 30;42
287              for world writable directories with sticky bit set
288
289       ow 34;43
290              for world writable directories without sticky bit set
291
292       sa none
293              for  files  with an associated suffix alias; this is only tested
294              after specific suffixes, as described below
295
296       st 37;44
297              for directories with sticky bit set but not world writable
298
299       ex 35  for executable files
300
301       lc \e[ for the left code (see below)
302
303       rc m   for the right code
304
305       tc 0   for the character indicating the file type  printed after  file‐
306              names if the LIST_TYPES option is set
307
308       sp 0   for the spaces printed after matches to align the next column
309
310       ec none
311              for the end code
312
313       Apart  from  these strings, the name may also be an asterisk (`*') fol‐
314       lowed by any string. The value given for such a string will be used for
315       all  files  whose  name  ends with the string.  The name may also be an
316       equals sign (`=') followed by a pattern; the EXTENDED_GLOB option  will
317       be  turned  on for evaluation of the pattern.  The value given for this
318       pattern will be used for all matches (not just filenames) whose display
319       string  are  matched by the pattern.  Definitions for the form with the
320       leading equal sign take precedence over the  values  defined  for  file
321       types,  which  in  turn  take precedence over the form with the leading
322       asterisk (file extensions).
323
324       The leading-equals form also allows different parts  of  the  displayed
325       strings  to  be  colored differently.  For this, the pattern has to use
326       the `(#b)' globbing flag and pairs of parentheses surrounding the parts
327       of  the  strings  that are to be colored differently.  In this case the
328       value may consist of more than one color code separated by equal signs.
329       The first code will be used for all parts for which no explicit code is
330       specified and the following codes will be used for the parts matched by
331       the  sub-patterns  in  parentheses.   For  example,  the  specification
332       `=(#b)(?)*(?)=0=3=7' will be used for all matches which  are  at  least
333       two  characters long and will use the code `3' for the first character,
334       `7' for the last character and `0' for the rest.
335
336       All three forms of name may be preceded by a  pattern  in  parentheses.
337       If  this  is  given,  the value will be used only for matches in groups
338       whose names are matched by the pattern given in the  parentheses.   For
339       example,  `(g*)m*=43'  highlights  all  matches  beginning  with `m' in
340       groups whose names  begin with `g' using the color code `43'.  In  case
341       of the `lc', `rc', and `ec' codes, the group pattern is ignored.
342
343       Note also that all patterns are tried in the order in which they appear
344       in the parameter value until the first one matches which is then  used.
345       Patterns  may  be  matched  against completions, descriptions (possibly
346       with spaces appended for padding), or lines consisting of a  completion
347       followed by a description.  For consistent coloring it may be necessary
348       to use more than one pattern or a pattern with backreferences.
349
350       When printing a match, the code prints the value of lc, the  value  for
351       the  file-type or the last matching specification with a `*', the value
352       of rc, the string to display for the match itself, and then  the  value
353       of  ec  if that is defined or the values of lc, no, and rc if ec is not
354       defined.
355
356       The default values are ISO 6429 (ANSI) compliant and  can  be  used  on
357       vt100 compatible terminals such as xterms.  On monochrome terminals the
358       default values will have no visible effect.  The colors  function  from
359       the  contribution  can be used to get associative arrays containing the
360       codes for ANSI terminals (see the section `Other Functions' in  zshcon‐
361       trib(1)).    For   example,   after   loading  colors,  one  could  use
362       `$color[red]'  to  get  the  code  for   foreground   color   red   and
363       `$color[bg-green]' for the code for background color green.
364
365       If  the completion system invoked by compinit is used, these parameters
366       should not be set directly because the  system  controls  them  itself.
367       Instead, the list-colors style should be used (see the section `Comple‐
368       tion System Configuration' in zshcompsys(1)).
369
370   Scrolling in completion listings
371       To enable scrolling through a completion list, the LISTPROMPT parameter
372       must  be set.  Its value will be used as the prompt; if it is the empty
373       string, a default prompt will be used.  The value may  contain  escapes
374       of  the  form  `%x'.   It  supports the escapes `%B', `%b', `%S', `%s',
375       `%U', `%u', `%F', `%f', `%K', `%k' and `%{...%}'  used  also  in  shell
376       prompts  as well as three pairs of additional sequences: a `%l' or `%L'
377       is replaced by the number of the last line shown and the  total  number
378       of  lines  in  the form `number/total'; a `%m' or `%M' is replaced with
379       the number of the last match shown and the total number of matches; and
380       `%p'  or  `%P'  is replaced with `Top', `Bottom' or the position of the
381       first line shown in percent of the total number of lines, respectively.
382       In  each  of  these  cases  the  form with the uppercase letter will be
383       replaced with a string of fixed width, padded to the right with spaces,
384       while the lowercase form will not be padded.
385
386       If the parameter LISTPROMPT is set, the completion code will not ask if
387       the list should be shown.  Instead it immediately starts displaying the
388       list,  stopping  after  the  first screenful, showing the prompt at the
389       bottom, waiting for a  keypress  after  temporarily  switching  to  the
390       listscroll  keymap.   Some  of the zle functions have a special meaning
391       while scrolling lists:
392
393       send-break
394              stops listing discarding the key pressed
395
396       accept-line, down-history, down-line-or-history
397       down-line-or-search, vi-down-line-or-history
398              scrolls forward one line
399
400       complete-word, menu-complete, expand-or-complete
401       expand-or-complete-prefix, menu-complete-or-expand
402              scrolls forward one screenful
403
404       accept-search
405              stop listing but take no other action
406
407       Every other character stops listing and immediately processes  the  key
408       as  usual.   Any key that is not bound in the listscroll keymap or that
409       is bound  to  undefined-key  is  looked  up  in  the  keymap  currently
410       selected.
411
412       As for the ZLS_COLORS and ZLS_COLOURS parameters, LISTPROMPT should not
413       be set directly when using the shell function based completion  system.
414       Instead, the list-prompt style should be used.
415
416   Menu selection
417       The  zsh/complist  module also offers an alternative style of selecting
418       matches from a list, called menu selection, which can be  used  if  the
419       shell is set up to return to the last prompt after showing a completion
420       list (see the ALWAYS_LAST_PROMPT option in zshoptions(1)).
421
422       Menu selection can  be  invoked  directly  by  the  widget  menu-select
423       defined  by  this  module.   This  is a standard ZLE widget that can be
424       bound to a key in the usual way as described in zshzle(1).
425
426       Alternatively, the parameter MENUSELECT can be set to an integer, which
427       gives  the  minimum  number of matches that must be present before menu
428       selection is automatically turned on.  This second method requires that
429       menu  completion  be  started,  either  directly  from a widget such as
430       menu-complete, or due to one of the options MENU_COMPLETE or  AUTO_MENU
431       being  set.  If MENUSELECT is set, but is 0, 1 or empty, menu selection
432       will always be started during an ambiguous menu completion.
433
434       When using the completion system based on shell functions, the  MENUSE‐
435       LECT  parameter should not be used (like the ZLS_COLORS and ZLS_COLOURS
436       parameters described above).  Instead, the menu style  should  be  used
437       with the select=... keyword.
438
439       After  menu  selection is started, the matches will be listed. If there
440       are more matches than fit on the screen, only the  first  screenful  is
441       shown.   The  matches  to  insert into the command line can be selected
442       from this list.  In the list one match is highlighted using  the  value
443       for ma from the ZLS_COLORS or ZLS_COLOURS parameter.  The default value
444       for this is `7' which forces the selected match to be highlighted using
445       standout  mode  on  a vt100-compatible terminal.  If neither ZLS_COLORS
446       nor ZLS_COLOURS is set, the same terminal control sequence as  for  the
447       `%S' escape in prompts is used.
448
449       If  there  are  more  matches  than fit on the screen and the parameter
450       MENUPROMPT is set, its value will be shown below the matches.  It  sup‐
451       ports  the  same  escape sequences as LISTPROMPT, but the number of the
452       match or line shown will be that of the one where the mark  is  placed.
453       If its value is the empty string, a default prompt will be used.
454
455       The  MENUSCROLL  parameter  can  be  used  to  specify  how the list is
456       scrolled.  If the parameter is unset, this is done line by line, if  it
457       is  set to `0' (zero), the list will scroll half the number of lines of
458       the screen.  If the value is positive, it gives the number of lines  to
459       scroll  and  if it is negative, the list will be scrolled the number of
460       lines of the screen minus the (absolute) value.
461
462       As for the ZLS_COLORS, ZLS_COLOURS and LISTPROMPT  parameters,  neither
463       MENUPROMPT  nor  MENUSCROLL should be set directly when using the shell
464       function based  completion  system.   Instead,  the  select-prompt  and
465       select-scroll styles should be used.
466
467       The completion code sometimes decides not to show all of the matches in
468       the list.  These hidden matches are either matches for which  the  com‐
469       pletion  function  which  added them explicitly requested that they not
470       appear in the list (using the -n option of the compadd builtin command)
471       or  they  are  matches  which  duplicate  a  string already in the list
472       (because they differ only in things like prefixes or suffixes that  are
473       not  displayed).   In  the  list used for menu selection, however, even
474       these matches are shown so that it is  possible  to  select  them.   To
475       highlight such matches the hi and du capabilities in the ZLS_COLORS and
476       ZLS_COLOURS parameters are supported for hidden matches  of  the  first
477       and second kind, respectively.
478
479       Selecting matches is done by moving the mark around using the zle move‐
480       ment functions.  When not all matches can be shown on the screen at the
481       same  time,  the  list will scroll up and down when crossing the top or
482       bottom line.  The following zle functions have special  meaning  during
483       menu  selection.   Note that the following always perform the same task
484       within the menu selection map and cannot be replaced  by  user  defined
485       widgets, nor can the set of functions be extended:
486
487       accept-line, accept-search
488              accept  the  current  match and leave menu selection (but do not
489              cause the command line to be accepted)
490
491       send-break
492              leaves menu selection and restores the previous contents of  the
493              command line
494
495       redisplay, clear-screen
496              execute their normal function without leaving menu selection
497
498       accept-and-hold, accept-and-menu-complete
499              accept  the  currently  inserted  match  and  continue selection
500              allowing to select the next match to insert into the line
501
502       accept-and-infer-next-history
503              accepts the current match and then tries  completion  with  menu
504              selection again;  in the case of files this allows one to select
505              a directory and immediately attempt to complete files in it;  if
506              there are no matches, a message is shown and one can use undo to
507              go back to completion on the previous  level,  every  other  key
508              leaves  menu  selection (including the other zle functions which
509              are otherwise special during menu selection)
510
511       undo   removes matches inserted during the menu selection by one of the
512              three functions before
513
514       down-history, down-line-or-history
515       vi-down-line-or-history,  down-line-or-search
516              moves the mark one line down
517
518       up-history, up-line-or-history
519       vi-up-line-or-history, up-line-or-search
520              moves the mark one line up
521
522       forward-char, vi-forward-char
523              moves the mark one column right
524
525       backward-char, vi-backward-char
526              moves the mark one column left
527
528       forward-word, vi-forward-word
529       vi-forward-word-end, emacs-forward-word
530              moves the mark one screenful down
531
532       backward-word, vi-backward-word, emacs-backward-word
533              moves the mark one screenful up
534
535       vi-forward-blank-word, vi-forward-blank-word-end
536              moves the mark to the first line of the next group of matches
537
538       vi-backward-blank-word
539              moves the mark to the last line of the previous group of matches
540
541       beginning-of-history
542              moves the mark to the first line
543
544       end-of-history
545              moves the mark to the last line
546
547       beginning-of-buffer-or-history, beginning-of-line
548       beginning-of-line-hist, vi-beginning-of-line
549              moves the mark to the leftmost column
550
551       end-of-buffer-or-history, end-of-line
552       end-of-line-hist, vi-end-of-line
553              moves the mark to the rightmost column
554
555       complete-word, menu-complete, expand-or-complete
556       expand-or-complete-prefix, menu-expand-or-complete
557              moves the mark to the next match
558
559       reverse-menu-complete
560              moves the mark to the previous match
561
562       vi-insert
563              this toggles between normal and interactive mode; in interactive
564              mode the keys bound to self-insert and self-insert-unmeta insert
565              into  the  command  line  as  in normal editing mode but without
566              leaving menu selection; after each character completion is tried
567              again  and the list changes to contain only the new matches; the
568              completion  widgets  make  the  longest  unambiguous  string  be
569              inserted  in  the command line and undo and backward-delete-char
570              go back to the previous set of matches
571
572       history-incremental-search-forward
573       history-incremental-search-backward
574              this starts incremental searches in the list of completions dis‐
575              played;  in  this  mode,  accept-line  only  leaves  incremental
576              search, going back to the normal menu selection mode
577
578       All movement functions wrap around at the edges; any other zle function
579       not  listed  leaves  menu  selection and executes that function.  It is
580       possible to make widgets in the above list do the  same  by  using  the
581       form  of  the  widget  with  a  `.'  in front.  For example, the widget
582       `.accept-line' has the effect of leaving menu selection  and  accepting
583       the entire command line.
584
585       During  this  selection the widget uses the keymap menuselect.  Any key
586       that is not defined in this keymap or that is bound to undefined-key is
587       looked  up  in  the  keymap currently selected.  This is used to ensure
588       that the most important keys used during selection (namely  the  cursor
589       keys,  return,  and  TAB) have sensible defaults.  However, keys in the
590       menuselect keymap can be modified directly using  the  bindkey  builtin
591       command  (see zshmodules(1)). For example, to make the return key leave
592       menu selection without accepting the match currently selected one could
593       call
594
595              bindkey -M menuselect '^M' send-break
596
597       after loading the zsh/complist module.
598

THE ZSH/COMPUTIL MODULE

600       The  zsh/computil module adds several builtin commands that are used by
601       some of the completion functions in  the  completion  system  based  on
602       shell  functions  (see  zshcompsys(1)  ).   Except  for compquote these
603       builtin commands are very specialised and  thus  not  very  interesting
604       when  writing your own completion functions.  In summary, these builtin
605       commands are:
606
607       comparguments
608              This is used by the _arguments function to do the  argument  and
609              command  line parsing.  Like compdescribe it has an option -i to
610              do the parsing and initialize some internal  state  and  various
611              options to access the state information to decide what should be
612              completed.
613
614       compdescribe
615              This is used by the _describe function to build the displays for
616              the  matches and to get the strings to add as matches with their
617              options.  On the first call one of the options -i or  -I  should
618              be  supplied  as the first argument.  In the first case, display
619              strings without the descriptions will be generated, in the  sec‐
620              ond  case,  the  string  used to separate the matches from their
621              descriptions must be  given  as  the  second  argument  and  the
622              descriptions  (if  any)  will be shown.  All other arguments are
623              like the definition arguments to _describe itself.
624
625              Once compdescribe has been called with either the -i or  the  -I
626              option,  it  can be repeatedly called with the -g option and the
627              names of four parameters  as  its  arguments.   This  will  step
628              through  the  different  sets  of matches and store the value of
629              compstate[list] in the first scalar, the options for compadd  in
630              the  second  array,  the  matches  in  the  third array, and the
631              strings to be displayed in the completion listing in the  fourth
632              array.  The arrays may then be directly given to compadd to reg‐
633              ister the matches with the completion code.
634
635       compfiles
636              Used by the _path_files function to optimize  complex  recursive
637              filename generation (globbing).  It does three things.  With the
638              -p and -P options it builds the glob patterns to use,  including
639              the  paths  already  handled and trying to optimize the patterns
640              with respect to the prefix and suffix  from  the  line  and  the
641              match  specification  currently  used.   The  -i option does the
642              directory tests for the ignore-parents style and the  -r  option
643              tests  if  a  component for some of the matches are equal to the
644              string on the line and removes all  other  matches  if  that  is
645              true.
646
647       compgroups
648              Used  by  the  _tags  function to implement the internals of the
649              group-order style.  This only takes its arguments  as  names  of
650              completion  groups and creates the groups for it (all six types:
651              sorted and unsorted,  both  without  removing  duplicates,  with
652              removing  all  duplicates  and  with removing consecutive dupli‐
653              cates).
654
655       compquote [ -p ] names ...
656              There may be reasons to write completion functions that have  to
657              add the matches using the -Q option to compadd and perform quot‐
658              ing themselves.  Instead of interpreting the first character  of
659              the  all_quotes  key  of  the  compstate special association and
660              using the q flag for parameter  expansions,  one  can  use  this
661              builtin command.  The arguments are the names of scalar or array
662              parameters and the values of  these  parameters  are  quoted  as
663              needed  for  the  innermost  quoting level.  If the -p option is
664              given, quoting is done as if there is  some  prefix  before  the
665              values  of the parameters, so that a leading equal sign will not
666              be quoted.
667
668              The return status is non-zero in case of an error and zero  oth‐
669              erwise.
670
671       comptags
672       comptry
673              These implement the internals of the tags mechanism.
674
675       compvalues
676              Like comparguments, but for the _values function.
677

THE ZSH/CURSES MODULE

679       The  zsh/curses  module makes available one builtin command and various
680       parameters.
681
682   Builtin
683       zcurses init
684       zcurses end
685       zcurses addwin targetwin nlines ncols begin_y begin_x [ parentwin ]
686       zcurses delwin targetwin
687       zcurses refresh [ targetwin ... ]
688       zcurses touch targetwin ...
689       zcurses move targetwin new_y new_x
690       zcurses clear targetwin [ redraw | eol | bot ]
691       zcurses position targetwin array
692       zcurses char targetwin character
693       zcurses string targetwin string
694       zcurses border targetwin border
695       zcurses attr targetwin [ [+|-]attribute | fg_col/bg_col ] [...]
696       zcurses bg targetwin [ [+|-]attribute | fg_col/bg_col | @char ] [...]
697       zcurses scroll targetwin [ on | off | [+|-]lines ]
698       zcurses input targetwin [ param [ kparam [ mparam ] ] ]
699       zcurses mouse [ delay num | [+|-]motion ]
700       zcurses timeout targetwin intval
701       zcurses querychar targetwin [ param ]
702       zcurses resize height width [ endwin | nosave | endwin_nosave ]
703              Manipulate curses windows.  All uses of this command  should  be
704              bracketed  by  `zcurses  init'  to initialise use of curses, and
705              `zcurses end' to end it; omitting `zcurses end'  can  cause  the
706              terminal to be in an unwanted state.
707
708              The  subcommand  addwin  creates  a window with nlines lines and
709              ncols columns.  Its upper left corner  will  be  placed  at  row
710              begin_y and column begin_x of the screen.  targetwin is a string
711              and refers to the  name  of  a  window  that  is  not  currently
712              assigned.   Note in particular the curses convention that verti‐
713              cal values appear before horizontal values.
714
715              If addwin is given an existing window as the final argument, the
716              new window is created as a subwindow of parentwin.  This differs
717              from an ordinary new window in that the  memory  of  the  window
718              contents is shared with the parent's memory.  Subwindows must be
719              deleted before their parent.  Note that the coordinates of  sub‐
720              windows  are  relative  to  the  screen, not the parent, as with
721              other windows.
722
723              Use the subcommand  delwin  to  delete  a  window  created  with
724              addwin.   Note  that end does not implicitly delete windows, and
725              that delwin does not erase the screen image of the window.
726
727              The window corresponding to the full visible  screen  is  called
728              stdscr;  it  always  exists  after  `zcurses init' and cannot be
729              delete with delwin.
730
731              The subcommand refresh will refresh window  targetwin;  this  is
732              necessary  to  make  any pending changes (such as characters you
733              have prepared for output  with  char)  visible  on  the  screen.
734              refresh  without an argument causes the screen to be cleared and
735              redrawn.  If multiple windows are given, the screen  is  updated
736              once at the end.
737
738              The  subcommand  touch  marks  the targetwins listed as changed.
739              This is necessary before refreshing windows if a window that was
740              in front of another window (which may be stdscr) is deleted.
741
742              The  subcommand  move  moves the cursor position in targetwin to
743              new coordinates new_y  and  new_x.   Note  that  the  subcommand
744              string  (but  not the subcommand char) advances the cursor posi‐
745              tion over the characters added.
746
747              The subcommand clear erases the contents of targetwin.  One (and
748              no  more  than one) of three options may be specified.  With the
749              option redraw, in addition the next refresh  of  targetwin  will
750              cause  the  screen to be cleared and repainted.  With the option
751              eol, targetwin is only cleared to the end of the current  cursor
752              line.   With  the option bot, targetwin is cleared to the end of
753              the window, i.e everything to the right and below the cursor  is
754              cleared.
755
756              The subcommand position writes various positions associated with
757              targetwin into the array named array.  These are, in order:
758              -      The y and x coordinates of the cursor relative to the top
759                     left of targetwin
760              -      The  y  and x coordinates of the top left of targetwin on
761                     the screen
762              -      The size of targetwin in y and x dimensions.
763
764              Outputting characters and  strings  are  achieved  by  char  and
765              string respectively.
766
767              To draw a border around window targetwin, use border.  Note that
768              the border is not  subsequently  handled  specially:   in  other
769              words,  the  border  is simply a set of characters output at the
770              edge of the window.  Hence it can be overwritten, can scroll off
771              the window, etc.
772
773              The  subcommand  attr  will  set targetwin's attributes or fore‐
774              ground/background color pair for any successive  character  out‐
775              put.   Each  attribute given on the line may be prepended by a +
776              to set or a - to unset that attribute; + is assumed  if  absent.
777              The  attributes  supported are blink, bold, dim, reverse, stand‐
778              out, and underline.
779
780              Each fg_col/bg_col attribute (to be read as `fg_col on  bg_col')
781              sets  the  foreground and background color for character output.
782              The color default is sometimes available (in particular  if  the
783              library  is  ncurses),  specifying  the foreground or background
784              color  with  which  the  terminal  started.   The   color   pair
785              default/default  is  always  available.  To  use more than the 8
786              named colors (red,  green,  etc.)  construct  the  fg_col/bg_col
787              pairs where fg_col and bg_col are decimal integers, e.g 128/200.
788              The maximum color value is 254 if the terminal supports 256 col‐
789              ors.
790
791              bg overrides the color and other attributes of all characters in
792              the window.  Its usual use is to set the  background  initially,
793              but  it  will  overwrite the attributes of any characters at the
794              time when it is called.  In addition to  the  arguments  allowed
795              with  attr,  an argument @char specifies a character to be shown
796              in otherwise blank areas of the window.  Owing to limitations of
797              curses  this cannot be a multibyte character (use of ASCII char‐
798              acters only is recommended).  As the specified set of attributes
799              override  the existing background, turning attributes off in the
800              arguments is not useful, though this does not cause an error.
801
802              The subcommand scroll can be used with on or off to  enabled  or
803              disable  scrolling  of  a window when the cursor would otherwise
804              move below the window due to typing or output.  It can  also  be
805              used with a positive or negative integer to scroll the window up
806              or down the given number of lines without changing  the  current
807              cursor position (which therefore appears to move in the opposite
808              direction relative to the  window).   In  the  second  case,  if
809              scrolling is off it is temporarily turned on to allow the window
810              to be scrolled.
811
812              The subcommand input reads a single character  from  the  window
813              without  echoing it back.  If param is supplied the character is
814              assigned to the parameter param, else  it  is  assigned  to  the
815              parameter REPLY.
816
817              If  both param and kparam are supplied, the key is read in `key‐
818              pad' mode.  In this mode special keys such as function keys  and
819              arrow  keys  return the name of the key in the parameter kparam.
820              The key  names  are  the  macros  defined  in  the  curses.h  or
821              ncurses.h  with the prefix `KEY_' removed; see also the descrip‐
822              tion of the parameter zcurses_keycodes below.  Other keys  cause
823              a  value  to  be set in param as before.  On a successful return
824              only one of param or kparam contains  a  non-empty  string;  the
825              other is set to an empty string.
826
827              If  mparam  is  also  supplied,  input  attempts to handle mouse
828              input.  This is only available with the ncurses  library;  mouse
829              handling  can  be  detected  by  checking for the exit status of
830              `zcurses mouse' with no arguments.  If a mouse button is clicked
831              (or  double-  or  triple-clicked,  or pressed or released with a
832              configurable delay from being clicked) then kparam is set to the
833              string  MOUSE,  and  mparam is set to an array consisting of the
834              following elements:
835              -      An identifier to discriminate  different  input  devices;
836                     this is only rarely useful.
837              -      The x, y and z coordinates of the mouse click relative to
838                     the full screen, as three elements in  that  order  (i.e.
839                     the  y coordinate is, unusually, after the x coordinate).
840                     The z coordinate is only  available  for  a  few  unusual
841                     input devices and is otherwise set to zero.
842              -      Any events that occurred as separate items; usually there
843                     will  be  just  one.   An  event  consists  of   PRESSED,
844                     RELEASED,  CLICKED, DOUBLE_CLICKED or TRIPLE_CLICKED fol‐
845                     lowed immediately (in the same element) by the number  of
846                     the button.
847              -      If the shift key was pressed, the string SHIFT.
848              -      If the control key was pressed, the string CTRL.
849              -      If the alt key was pressed, the string ALT.
850
851              Not  all mouse events may be passed through to the terminal win‐
852              dow; most terminal emulators  handle  some  mouse  events  them‐
853              selves.   Note  that the ncurses manual implies that using input
854              both with and without mouse handling may cause the mouse  cursor
855              to appear and disappear.
856
857              The  subcommand  mouse  can  be used to configure the use of the
858              mouse.  There is no window argument; mouse options  are  global.
859              `zcurses mouse' with no arguments returns status 0 if mouse han‐
860              dling is possible, else status 1.  Otherwise, the possible argu‐
861              ments  (which  may  be combined on the same command line) are as
862              follows.  delay num  sets  the  maximum  delay  in  milliseconds
863              between  press  and  release events to be considered as a click;
864              the value 0 disables click resolution, and the  default  is  one
865              sixth  of  a  second.   motion proceeded by an optional `+' (the
866              default) or - turns on or off reporting of mouse motion in addi‐
867              tion to clicks, presses and releases, which are always reported.
868              However, it appears reports for mouse motion are  not  currently
869              implemented.
870
871              The  subcommand timeout specifies a timeout value for input from
872              targetwin.  If intval is negative, `zcurses input' waits indefi‐
873              nitely  for  a  character  to be typed; this is the default.  If
874              intval is zero, `zcurses input' returns immediately; if there is
875              typeahead  it is returned, else no input is done and status 1 is
876              returned.  If intval is positive, `zcurses input'  waits  intval
877              milliseconds  for  input and if there is none at the end of that
878              period returns status 1.
879
880              The subcommand querychar queries the character  at  the  current
881              cursor  position.   The  return  values  are stored in the array
882              named param if supplied, else in the  array  reply.   The  first
883              value  is  the  character (which may be a multibyte character if
884              the system supports them); the second is the color pair  in  the
885              usual  fg_col/bg_col  notation,  or 0 if color is not supported.
886              Any attributes other than color that apply to the character,  as
887              set with the subcommand attr, appear as additional elements.
888
889              The  subcommand  resize  resizes stdscr and all windows to given
890              dimensions (windows that stick out from the new  dimensions  are
891              resized  down).  The  underlying  curses  extension (resize_term
892              call) can be unavailable. To verify,  zeroes  can  be  used  for
893              height  and  width.  If  the  result  of  the  subcommand  is 0,
894              resize_term is available (2 otherwise). Tests show that resizing
895              can  be normally accomplished by calling zcurses end and zcurses
896              refresh. The resize subcommand is provided for versatility. Mul‐
897              tiple  system  configurations  have been checked and zcurses end
898              and zcurses refresh are still needed for correct terminal  state
899              after  resize.  To invoke them with resize, use endwin argument.
900              Using nosave argument will cause new terminal state  to  not  be
901              saved internally by zcurses. This is also provided for versatil‐
902              ity and should normally be not needed.
903
904   Parameters
905       ZCURSES_COLORS
906              Readonly integer.  The maximum number  of  colors  the  terminal
907              supports.   This  value is initialised by the curses library and
908              is not available until the first time zcurses init is run.
909
910       ZCURSES_COLOR_PAIRS
911              Readonly  integer.   The   maximum   number   of   color   pairs
912              fg_col/bg_col  that  may  be defined in `zcurses attr' commands;
913              note this limit applies to all color pairs that have  been  used
914              whether  or  not  they are currently active.  This value is ini‐
915              tialised by the curses library and is not  available  until  the
916              first time zcurses init is run.
917
918       zcurses_attrs
919              Readonly  array.  The attributes supported by zsh/curses; avail‐
920              able as soon as the module is loaded.
921
922       zcurses_colors
923              Readonly array.  The colors supported by  zsh/curses;  available
924              as soon as the module is loaded.
925
926       zcurses_keycodes
927              Readonly  array.   The values that may be returned in the second
928              parameter supplied to `zcurses input' in the order in which they
929              are  defined  internally  by  curses.  Not all function keys are
930              listed, only F0; curses reserves space for F0 up to F63.
931
932       zcurses_windows
933              Readonly array.  The current list of windows, i.e.  all  windows
934              that  have  been  created  with `zcurses addwin' and not removed
935              with `zcurses delwin'.
936

THE ZSH/DATETIME MODULE

938       The zsh/datetime module makes available one builtin command:
939
940       strftime [ -s scalar ] format epochtime
941       strftime -r [ -q ] [ -s scalar ] format timestring
942              Output the date denoted by epochtime in  the  format  specified.
943              See  strftime(3)  for  details.  The zsh extensions described in
944              the section EXPANSION OF PROMPT SEQUENCES in zshmisc(1) are also
945              available.
946
947              -q     Run  quietly;  suppress  printing  of  all error messages
948                     described below.  Errors for invalid epochtime values are
949                     always printed.
950
951              -r     With  the  option  -r  (reverse), use format to parse the
952                     input string timestring and output the number of  seconds
953                     since  the epoch at which the time occurred.  The parsing
954                     is implemented by the system function strptime; see strp‐
955                     time(3).   This  means that zsh format extensions are not
956                     available, but for reverse lookup they are not required.
957
958                     In most implementations of strftime any timezone  in  the
959                     timestring  is ignored and the local timezone declared by
960                     the TZ environment variable is used; other parameters are
961                     set to zero if not present.
962
963                     If  timestring  does not match format the command returns
964                     status 1 and prints  an  error  message.   If  timestring
965                     matches  format but not all characters in timestring were
966                     used, the conversion succeeds but also  prints  an  error
967                     message.
968
969                     If  either  of the system functions strptime or mktime is
970                     not available, status 2 is returned and an error  message
971                     is printed.
972
973              -s scalar
974                     Assign the date string (or epoch time in seconds if -r is
975                     given) to scalar instead of printing it.
976
977              Note that depending on the system's declared integral time type,
978              strftime  may  produce incorrect results for epoch times greater
979              than 2147483647 which corresponds to 2038-01-19 03:14:07 +0000.
980
981       The zsh/datetime module makes available  several  parameters;  all  are
982       readonly:
983
984       EPOCHREALTIME
985              A  floating point value representing the number of seconds since
986              the epoch.  The notional  accuracy  is  to  nanoseconds  if  the
987              clock_gettime  call  is available and to microseconds otherwise,
988              but in practice the range of double precision floating point and
989              shell scheduling latencies may be significant effects.
990
991       EPOCHSECONDS
992              An  integer  value  representing the number of seconds since the
993              epoch.
994
995       epochtime
996              An array value containing the number of seconds since the  epoch
997              in  the  first  element  and the remainder of the time since the
998              epoch in nanoseconds in the second element.  To ensure  the  two
999              elements  are consistent the array should be copied or otherwise
1000              referenced as a single substitution before the values are  used.
1001              The following idiom may be used:
1002
1003                     for secs nsecs in $epochtime; do
1004                       ...
1005                     done
1006

THE ZSH/DB/GDBM MODULE

1008       The zsh/db/gdbm module is used to create "tied" associative arrays that
1009       interface to database files.  If the GDBM interface is  not  available,
1010       the  builtins defined by this module will report an error.  This module
1011       is also intended as a prototype for creating additional database inter‐
1012       faces,  so  the  ztie  builtin may move to a more generic module in the
1013       future.
1014
1015       The builtins in this module are:
1016
1017       ztie -d db/gdbm -f filename [ -r ] arrayname
1018              Open the GDBM database identified by filename and,  if  success‐
1019              ful,  create the associative array arrayname linked to the file.
1020              To create a local  tied  array,  the  parameter  must  first  be
1021              declared, so commands similar to the following would be executed
1022              inside a function scope:
1023
1024                     local -A sampledb
1025                     ztie -d db/gdbm -f sample.gdbm sampledb
1026
1027              The -r option opens the database file for reading only, creating
1028              a  parameter  with the readonly attribute.  Without this option,
1029              using `ztie' on a file for which the user does  not  have  write
1030              permission  is  an  error.   If writable, the database is opened
1031              synchronously so fields changed  in  arrayname  are  immediately
1032              written to filename.
1033
1034              Changes  to  the file modes filename after it has been opened do
1035              not alter the state of arrayname,  but  `typeset  -r  arrayname'
1036              works as expected.
1037
1038       zuntie [ -u ] arrayname ...
1039              Close  the GDBM database associated with each arrayname and then
1040              unset the parameter.  The -u option forces an unset  of  parame‐
1041              ters made readonly with `ztie -r'.
1042
1043              This  happens automatically if the parameter is explicitly unset
1044              or its local scope (function) ends.  Note that a readonly param‐
1045              eter  may  not  be  explicitly unset, so the only way to unset a
1046              global parameter created with `ztie -r' is to use `zuntie -u'.
1047
1048       zgdbmpath parametername
1049              Put path to database file assigned to parametername  into  REPLY
1050              scalar.
1051
1052       zgdbm_tied
1053              Array holding names of all tied parameters.
1054
1055       The  fields of an associative array tied to GDBM are neither cached nor
1056       otherwise stored in memory, they are read from or written to the  data‐
1057       base  on  each  reference.  Thus, for example, the values in a readonly
1058       array may be changed by a second writer of the same database file.
1059

THE ZSH/DELTOCHAR MODULE

1061       The zsh/deltochar module makes available two ZLE functions:
1062
1063       delete-to-char
1064              Read a character from the keyboard, and delete from  the  cursor
1065              position  up to and including the next (or, with repeat count n,
1066              the nth) instance of that  character.   Negative  repeat  counts
1067              mean delete backwards.
1068
1069       zap-to-char
1070              This  behaves  like delete-to-char, except that the final occur‐
1071              rence of the character itself is not deleted.
1072

THE ZSH/EXAMPLE MODULE

1074       The zsh/example module makes available one builtin command:
1075
1076       example [ -flags ] [ args ... ]
1077              Displays the flags and arguments it is invoked with.
1078
1079       The purpose of the module is to serve as an example of how to  write  a
1080       module.
1081

THE ZSH/FILES MODULE

1083       The  zsh/files  module  makes  available  some common commands for file
1084       manipulation as builtins; these commands are probably  not  needed  for
1085       many  normal  situations but can be useful in emergency recovery situa‐
1086       tions with constrained resources.  The commands do  not  implement  all
1087       features now required by relevant standards committees.
1088
1089       For  all commands, a variant beginning zf_ is also available and loaded
1090       automatically.  Using the features capability of zmodload will let  you
1091       load  only  those names you want.  Note that it's possible to load only
1092       the builtins with zsh-specific names using the following command:
1093
1094              zmodload -m -F zsh/files b:zf_\*
1095
1096       The commands loaded by default are:
1097
1098       chgrp [ -hRs ] group filename ...
1099              Changes group of files specified.  This is equivalent  to  chown
1100              with a user-spec argument of `:group'.
1101
1102       chown [ -hRs ] user-spec filename ...
1103              Changes ownership and group of files specified.
1104
1105              The user-spec can be in four forms:
1106
1107              user   change owner to user; do not change group
1108              user:: change owner to user; do not change group
1109              user:  change  owner  to  user;  change  group to user's primary
1110                     group
1111              user:group
1112                     change owner to user; change group to group
1113              :group do not change owner; change group to group
1114
1115              In each case, the `:' may instead be a `.'.  The rule is that if
1116              there  is a `:' then the separator is `:', otherwise if there is
1117              a `.' then the separator is `.', otherwise there is  no  separa‐
1118              tor.
1119
1120              Each  of user and group may be either a username (or group name,
1121              as appropriate) or a decimal user ID (group ID).  Interpretation
1122              as  a name takes precedence, if there is an all-numeric username
1123              (or group name).
1124
1125              If the target is a symbolic link, the -h option causes chown  to
1126              set the ownership of the link instead of its target.
1127
1128              The  -R option causes chown to recursively descend into directo‐
1129              ries, changing the ownership of all files in the directory after
1130              changing the ownership of the directory itself.
1131
1132              The  -s  option  is  a zsh extension to chown functionality.  It
1133              enables paranoid behaviour, intended to avoid security  problems
1134              involving  a chown being tricked into affecting files other than
1135              the ones intended.  It will refuse to follow symbolic links,  so
1136              that  (for  example) ``chown luser /tmp/foo/passwd'' can't acci‐
1137              dentally chown /etc/passwd if /tmp/foo happens to be a  link  to
1138              /etc.  It will also check where it is after leaving directories,
1139              so that a recursive chown of a deep directory tree can't end  up
1140              recursively chowning /usr as a result of directories being moved
1141              up the tree.
1142
1143       ln [ -dfhins ] filename dest
1144       ln [ -dfhins ] filename ... dir
1145              Creates hard (or, with -s, symbolic) links.  In the first  form,
1146              the specified destination is created, as a link to the specified
1147              filename.  In the second form, each of the filenames is taken in
1148              turn,  and  linked to a pathname in the specified directory that
1149              has the same last pathname component.
1150
1151              Normally, ln will not attempt to create hard links  to  directo‐
1152              ries.   This check can be overridden using the -d option.  Typi‐
1153              cally only the super-user can actually succeed in creating  hard
1154              links  to directories.  This does not apply to symbolic links in
1155              any case.
1156
1157              By default, existing files cannot be replaced by links.  The  -i
1158              option  causes  the  user to be queried about replacing existing
1159              files.  The -f option  causes  existing  files  to  be  silently
1160              deleted, without querying.  -f takes precedence.
1161
1162              The  -h and -n options are identical and both exist for compati‐
1163              bility; either one indicates that if the  target  is  a  symlink
1164              then  it  should not be dereferenced.  Typically this is used in
1165              combination with -sf so that if an existing  link  points  to  a
1166              directory then it will be removed, instead of followed.  If this
1167              option is used with multiple filenames and the target is a  sym‐
1168              bolic link pointing to a directory then the result is an error.
1169
1170       mkdir [ -p ] [ -m mode ] dir ...
1171              Creates  directories.   With  the -p option, non-existing parent
1172              directories are first created if necessary, and there will be no
1173              complaint if the directory already exists.  The -m option can be
1174              used to specify (in octal) a set of  file  permissions  for  the
1175              created  directories, otherwise mode 777 modified by the current
1176              umask (see umask(2)) is used.
1177
1178       mv [ -fi ] filename dest
1179       mv [ -fi ] filename ... dir
1180              Moves files.  In the first form, the specified filename is moved
1181              to  the  specified destination.  In the second form, each of the
1182              filenames is taken in turn, and moved to a pathname in the spec‐
1183              ified directory that has the same last pathname component.
1184
1185              By  default,  the user will be queried before replacing any file
1186              that the user cannot  write  to,  but  writable  files  will  be
1187              silently  removed.   The -i option causes the user to be queried
1188              about replacing any existing files.  The -f  option  causes  any
1189              existing  files  to  be  silently deleted, without querying.  -f
1190              takes precedence.
1191
1192              Note that this mv will not move files across devices.   Histori‐
1193              cal  versions  of  mv,  when actual renaming is impossible, fall
1194              back on  copying  and  removing  files;  if  this  behaviour  is
1195              desired,  use  cp  and rm manually.  This may change in a future
1196              version.
1197
1198       rm [ -dfirs ] filename ...
1199              Removes files and directories specified.
1200
1201              Normally, rm will not remove directories  (except  with  the  -r
1202              option).   The  -d  option causes rm to try removing directories
1203              with unlink (see unlink(2)), the same  method  used  for  files.
1204              Typically  only the super-user can actually succeed in unlinking
1205              directories in this way.  -d takes precedence over -r.
1206
1207              By default, the user will be queried before  removing  any  file
1208              that  the  user  cannot  write  to,  but  writable files will be
1209              silently removed.  The -i option causes the user to  be  queried
1210              about  removing  any  files.   The  -f option causes files to be
1211              silently deleted, without querying,  and  suppresses  all  error
1212              indications.  -f takes precedence.
1213
1214              The -r option causes rm to recursively descend into directories,
1215              deleting all files in the directory before removing  the  direc‐
1216              tory with the rmdir system call (see rmdir(2)).
1217
1218              The  -s  option  is  a  zsh  extension  to rm functionality.  It
1219              enables paranoid behaviour, intended to  avoid  common  security
1220              problems  involving  a  root-run  rm being tricked into removing
1221              files other than the ones intended.  It will  refuse  to  follow
1222              symbolic  links,  so  that  (for example) ``rm /tmp/foo/passwd''
1223              can't accidentally remove /etc/passwd if /tmp/foo happens to  be
1224              a  link  to  /etc.  It will also check where it is after leaving
1225              directories, so that a recursive removal  of  a  deep  directory
1226              tree  can't  end  up  recursively  removing  /usr as a result of
1227              directories being moved up the tree.
1228
1229       rmdir dir ...
1230              Removes empty directories specified.
1231
1232       sync   Calls the system call of the  same  name  (see  sync(2)),  which
1233              flushes  dirty  buffers to disk.  It might return before the I/O
1234              has actually been completed.
1235

THE ZSH/LANGINFO MODULE

1237       The zsh/langinfo module makes available one parameter:
1238
1239       langinfo
1240              An associative array that maps langinfo elements to  their  val‐
1241              ues.
1242
1243              Your implementation may support a number of the following keys:
1244
1245              CODESET,  D_T_FMT,  D_FMT,  T_FMT,  RADIXCHAR, THOUSEP, YESEXPR,
1246              NOEXPR,  CRNCYSTR,  ABDAY_{1..7},   DAY_{1..7},   ABMON_{1..12},
1247              MON_{1..12},   T_FMT_AMPM,   AM_STR,   PM_STR,  ERA,  ERA_D_FMT,
1248              ERA_D_T_FMT, ERA_T_FMT, ALT_DIGITS
1249

THE ZSH/MAPFILE MODULE

1251       The zsh/mapfile module provides one special associative array parameter
1252       of the same name.
1253
1254       mapfile
1255              This  associative  array  takes  as keys the names of files; the
1256              resulting value is the  content  of  the  file.   The  value  is
1257              treated  identically  to any other text coming from a parameter.
1258              The value may also be assigned to, in which  case  the  file  in
1259              question  is  written (whether or not it originally existed); or
1260              an element may be unset, which will delete the file in question.
1261              For  example, `vared mapfile[myfile]' works as expected, editing
1262              the file `myfile'.
1263
1264              When the array is accessed as a whole, the keys are the names of
1265              files  in  the  current  directory, and the values are empty (to
1266              save a huge overhead in memory).   Thus  ${(k)mapfile}  has  the
1267              same  affect  as  the  glob operator *(D), since files beginning
1268              with a dot are not special.  Care must be taken with expressions
1269              such  as  rm  ${(k)mapfile}, which will delete every file in the
1270              current directory without the usual `rm *' test.
1271
1272              The parameter mapfile may be made read-only; in that case, files
1273              referenced may not be written or deleted.
1274
1275              A  file  may  conveniently be read into an array as one line per
1276              element with the form `array=("${(f@)mapfile[filename]}")'.  The
1277              double  quotes  and the `@' are necessary to prevent empty lines
1278              from being removed.  Note that if the file ends with a  newline,
1279              the  shell  will split on the final newline, generating an addi‐
1280              tional  empty  field;  this   can   be   suppressed   by   using
1281              `array=("${(f@)${mapfile[filename]%$'\n'}}")'.
1282
1283   Limitations
1284       Although  reading  and  writing  of the file in question is efficiently
1285       handled, zsh's internal memory management may be  arbitrarily  baroque;
1286       however,  mapfile  is  usually  very  much more efficient than anything
1287       involving a loop.  Note in particular that the whole  contents  of  the
1288       file  will  always  reside physically in memory when accessed (possibly
1289       multiple times, due to standard parameter substitution operations).  In
1290       particular,  this  means  handling  of sufficiently long files (greater
1291       than the machine's swap space, or than the range of the  pointer  type)
1292       will be incorrect.
1293
1294       No  errors  are  printed  or  flagged  for non-existent, unreadable, or
1295       unwritable files, as the parameter mechanism is too low  in  the  shell
1296       execution hierarchy to make this convenient.
1297
1298       It  is  unfortunate that the mechanism for loading modules does not yet
1299       allow the user to specify the name of the shell parameter to  be  given
1300       the special behaviour.
1301

THE ZSH/MATHFUNC MODULE

1303       The  zsh/mathfunc  module  provides standard mathematical functions for
1304       use when evaluating mathematical formulae.  The syntax agrees with nor‐
1305       mal C and FORTRAN conventions, for example,
1306
1307              (( f = sin(0.3) ))
1308
1309       assigns the sine of 0.3 to the parameter f.
1310
1311       Most  functions  take  floating  point  arguments and return a floating
1312       point value.  However, any necessary conversions  from  or  to  integer
1313       type  will  be  performed  automatically by the shell.  Apart from atan
1314       with a second argument and the abs, int and float functions, all  func‐
1315       tions  behave as noted in the manual page for the corresponding C func‐
1316       tion, except that any arguments out of range for the function in  ques‐
1317       tion will be detected by the shell and an error reported.
1318
1319       The  following  functions  take a single floating point argument: acos,
1320       acosh, asin, asinh, atan, atanh, cbrt, ceil, cos, cosh, erf, erfc, exp,
1321       expm1,  fabs,  floor,  gamma,  j0, j1, lgamma, log, log10, log1p, logb,
1322       sin, sinh, sqrt, tan, tanh, y0, y1.  The atan function  can  optionally
1323       take  a  second  argument, in which case it behaves like the C function
1324       atan2.  The ilogb function takes a single floating point argument,  but
1325       returns an integer.
1326
1327       The  function signgam takes no arguments, and returns an integer, which
1328       is the C variable of the same name, as  described  in  gamma(3).   Note
1329       that  it  is therefore only useful immediately after a call to gamma or
1330       lgamma.  Note also that `signgam()' and `signgam' are distinct  expres‐
1331       sions.
1332
1333       The  functions  min, max, and sum are defined not in this module but in
1334       the zmathfunc autoloadable function, described in the  section  `Mathe‐
1335       matical Functions' in zshcontrib(1).
1336
1337       The  following  functions  take two floating point arguments: copysign,
1338       fmod, hypot, nextafter.
1339
1340       The following take an integer first argument and a floating point  sec‐
1341       ond argument: jn, yn.
1342
1343       The  following take a floating point first argument and an integer sec‐
1344       ond argument: ldexp, scalb.
1345
1346       The function abs does not convert the type of its single  argument;  it
1347       returns  the  absolute  value  of  either a floating point number or an
1348       integer.  The functions float and int convert their  arguments  into  a
1349       floating point or integer value (by truncation) respectively.
1350
1351       Note  that  the C pow function is available in ordinary math evaluation
1352       as the `**' operator and is not provided here.
1353
1354       The function rand48 is available if your system's mathematical  library
1355       has the function erand48(3).  It returns a pseudo-random floating point
1356       number between 0 and 1.  It takes a single string optional argument.
1357
1358       If the argument is not present, the random number seed  is  initialised
1359       by  three calls to the rand(3) function --- this produces the same ran‐
1360       dom numbers as the next three values of $RANDOM.
1361
1362       If the argument is present, it gives the name  of  a  scalar  parameter
1363       where  the  current  random  number  seed will be stored.  On the first
1364       call, the value must contain at least twelve  hexadecimal  digits  (the
1365       remainder of the string is ignored), or the seed will be initialised in
1366       the same manner as for a call to rand48 with no  argument.   Subsequent
1367       calls  to  rand48(param)  will  then maintain the seed in the parameter
1368       param as a string of twelve hexadecimal digits, with no base signifier.
1369       The  random  number  sequences  for different parameters are completely
1370       independent, and are also independent from that used by calls to rand48
1371       with no argument.
1372
1373       For example, consider
1374
1375              print $(( rand48(seed) ))
1376              print $(( rand48() ))
1377              print $(( rand48(seed) ))
1378
1379       Assuming  $seed  does  not  exist,  it will be initialised by the first
1380       call.  In the second call, the default seed is initialised; note,  how‐
1381       ever,  that  because of the properties of rand() there is a correlation
1382       between the seeds used for the two initialisations, so for more  secure
1383       uses,  you  should  generate  your  own  12-byte  seed.  The third call
1384       returns to the same sequence of random numbers used in the first  call,
1385       unaffected by the intervening rand48().
1386

THE ZSH/NEWUSER MODULE

1388       The  zsh/newuser  module  is loaded at boot if it is available, the RCS
1389       option is set, and the PRIVILEGED option is not set (all three are true
1390       by default).  This takes place immediately after commands in the global
1391       zshenv file (typically /etc/zshenv), if any, have  been  executed.   If
1392       the  module  is  not available it is silently ignored by the shell; the
1393       module may safely be removed from $MODULE_PATH by the administrator  if
1394       it is not required.
1395
1396       On  loading,  the  module  tests  if any of the start-up files .zshenv,
1397       .zprofile, .zshrc or .zlogin exist in the directory given by the  envi‐
1398       ronment  variable  ZDOTDIR, or the user's home directory if that is not
1399       set.  The test is not performed and the module halts processing if  the
1400       shell  was  in  an  emulation mode (i.e. had been invoked as some other
1401       shell than zsh).
1402
1403       If none of the start-up files were found, the module then looks for the
1404       file  newuser  first in a sitewide directory, usually the parent direc‐
1405       tory of the site-functions directory, and if that is not found the mod‐
1406       ule searches in a version-specific directory, usually the parent of the
1407       functions  directory  containing  version-specific  functions.   (These
1408       directories   can   be   configured   when   zsh  is  built  using  the
1409       --enable-site-scriptdir=dir and --enable-scriptdir=dir flags to config‐
1410       ure,   respectively;   the   defaults  are  prefix/share/zsh  and  pre‐
1411       fix/share/zsh/$ZSH_VERSION where the default prefix is /usr/local.)
1412
1413       If the file newuser is found, it is then sourced in the same manner  as
1414       a  start-up  file.   The  file  is  expected to contain code to install
1415       start-up files for the user, however any valid shell code will be  exe‐
1416       cuted.
1417
1418       The zsh/newuser module is then unconditionally unloaded.
1419
1420       Note  that  it  is  possible  to achieve exactly the same effect as the
1421       zsh/newuser module by adding code to /etc/zshenv.   The  module  exists
1422       simply  to  allow  the shell to make arrangements for new users without
1423       the need for intervention by package maintainers and system administra‐
1424       tors.
1425
1426       The  script  supplied  with  the  module  invokes  the  shell  function
1427       zsh-newuser-install.  This may be invoked directly by the user even  if
1428       the  zsh/newuser module is disabled.  Note, however, that if the module
1429       is not installed the function will not be installed either.  The  func‐
1430       tion  is documented in the section User Configuration Functions in zsh‐
1431       contrib(1).
1432

THE ZSH/PARAMETER MODULE

1434       The zsh/parameter module gives access to  some  of  the  internal  hash
1435       tables used by the shell by defining some special parameters.
1436
1437       options
1438              The keys for this associative array are the names of the options
1439              that can  be  set  and  unset  using  the  setopt  and  unsetopt
1440              builtins.  The  value of each key is either the string on if the
1441              option is currently set, or the string  off  if  the  option  is
1442              unset.  Setting a key to one of these strings is like setting or
1443              unsetting the option, respectively.  Unsetting  a  key  in  this
1444              array is like setting it to the value off.
1445
1446       commands
1447              This  array gives access to the command hash table. The keys are
1448              the names of external commands, the values are the pathnames  of
1449              the  files  that  would  be  executed  when the command would be
1450              invoked. Setting a key in this array defines a new entry in this
1451              table  in the same way as with the hash builtin. Unsetting a key
1452              as in `unset "commands[foo]"' removes the entry  for  the  given
1453              key from the command hash table.
1454
1455       functions
1456              This  associative array maps names of enabled functions to their
1457              definitions. Setting a key in it is  like  defining  a  function
1458              with  the name given by the key and the body given by the value.
1459              Unsetting a key removes the definition for the function named by
1460              the key.
1461
1462       dis_functions
1463              Like functions but for disabled functions.
1464
1465       functions_source
1466              This  readonly associative array maps names of enabled functions
1467              to the name of the file containing the source of the function.
1468
1469              For an autoloaded function that  has  already  been  loaded,  or
1470              marked  for  autoload with an absolute path, or that has had its
1471              path resolved with `functions -r', this is the  file  found  for
1472              autoloading, resolved to an absolute path.
1473
1474              For  a  function  defined within the body of a script or sourced
1475              file, this is the name of that file.  In this case, this is  the
1476              exact path originally used to that file, which may be a relative
1477              path.
1478
1479              For any other function, including any defined at an  interactive
1480              prompt  or  an  autoload  function  whose  path has not yet been
1481              resolved, this is the empty string.  However, the  hash  element
1482              is  reported as defined just so long as the function is present:
1483              the keys to this hash are the same as those to $funcions.
1484
1485       dis_functions_source
1486              Like functions_source but for disabled functions.
1487
1488       builtins
1489              This associative array gives information about the builtin  com‐
1490              mands  currently  enabled. The keys are the names of the builtin
1491              commands and the values are either `undefined' for builtin  com‐
1492              mands that will automatically be loaded from a module if invoked
1493              or `defined' for builtin commands that are already loaded.
1494
1495       dis_builtins
1496              Like builtins but for disabled builtin commands.
1497
1498       reswords
1499              This array contains the enabled reserved words.
1500
1501       dis_reswords
1502              Like reswords but for disabled reserved words.
1503
1504       patchars
1505              This array contains the enabled pattern characters.
1506
1507       dis_patchars
1508              Like patchars but for disabled pattern characters.
1509
1510       aliases
1511              This maps the names of the regular aliases currently enabled  to
1512              their expansions.
1513
1514       dis_aliases
1515              Like aliases but for disabled regular aliases.
1516
1517       galiases
1518              Like aliases, but for global aliases.
1519
1520       dis_galiases
1521              Like galiases but for disabled global aliases.
1522
1523       saliases
1524              Like raliases, but for suffix aliases.
1525
1526       dis_saliases
1527              Like saliases but for disabled suffix aliases.
1528
1529       parameters
1530              The  keys in this associative array are the names of the parame‐
1531              ters currently defined. The values are  strings  describing  the
1532              type  of the parameter, in the same format used by the t parame‐
1533              ter flag, see zshexpn(1) .  Setting or unsetting  keys  in  this
1534              array is not possible.
1535
1536       modules
1537              An  associative array giving information about modules. The keys
1538              are  the  names  of  the  modules  loaded,  registered   to   be
1539              autoloaded,  or  aliased.  The  value says which state the named
1540              module is in and is one of the strings  `loaded',  `autoloaded',
1541              or  `alias:name',  where  name is the name the module is aliased
1542              to.
1543
1544              Setting or unsetting keys in this array is not possible.
1545
1546       dirstack
1547              A normal array holding the elements of the directory stack. Note
1548              that  the  output  of the dirs builtin command includes one more
1549              directory, the current working directory.
1550
1551       history
1552              This associative array maps history event numbers  to  the  full
1553              history  lines.   Although  it  is  presented  as an associative
1554              array, the array of all values (${history[@]}) is guaranteed  to
1555              be  returned  in order from most recent to oldest history event,
1556              that is, by decreasing history event number.
1557
1558       historywords
1559              A special array containing the  words  stored  in  the  history.
1560              These also appear in most to least recent order.
1561
1562       jobdirs
1563              This  associative array maps job numbers to the directories from
1564              which the job was started (which may not be the  current  direc‐
1565              tory of the job).
1566
1567              The  keys  of  the associative arrays are usually valid job num‐
1568              bers, and  these  are  the  values  output  with,  for  example,
1569              ${(k)jobdirs}.   Non-numeric  job  references  may  be used when
1570              looking up a value; for example, ${jobdirs[%+]}  refers  to  the
1571              current job.
1572
1573       jobtexts
1574              This associative array maps job numbers to the texts of the com‐
1575              mand lines that were used to start the jobs.
1576
1577              Handling of the keys of the associative array  is  as  described
1578              for jobdirs above.
1579
1580       jobstates
1581              This associative array gives information about the states of the
1582              jobs currently known. The keys are the job numbers and the  val‐
1583              ues  are  strings of the form `job-state:mark:pid=state...'. The
1584              job-state gives the state the whole job is currently in, one  of
1585              `running',  `suspended', or `done'. The mark is `+' for the cur‐
1586              rent job, `-' for the previous job and empty otherwise. This  is
1587              followed  by  one `:pid=state' for every process in the job. The
1588              pids are, of course, the process IDs and the state describes the
1589              state of that process.
1590
1591              Handling  of  the  keys of the associative array is as described
1592              for jobdirs above.
1593
1594       nameddirs
1595              This associative array maps the names of  named  directories  to
1596              the pathnames they stand for.
1597
1598       userdirs
1599              This associative array maps user names to the pathnames of their
1600              home directories.
1601
1602       usergroups
1603              This associative array maps names of system groups of which  the
1604              current user is a member to the corresponding group identifiers.
1605              The contents are the same as the groups output by  the  id  com‐
1606              mand.
1607
1608       funcfiletrace
1609              This  array contains the absolute line numbers and corresponding
1610              file names for the point where  the  current  function,  sourced
1611              file,  or  (if EVAL_LINENO is set) eval command was called.  The
1612              array is of the same length as  funcsourcetrace  and  functrace,
1613              but  differs  from funcsourcetrace in that the line and file are
1614              the point of call, not the point of definition, and differs from
1615              functrace in that all values are absolute line numbers in files,
1616              rather than relative to the start of a function, if any.
1617
1618       funcsourcetrace
1619              This array contains the file  names  and  line  numbers  of  the
1620              points  where  the functions, sourced files, and (if EVAL_LINENO
1621              is set) eval commands currently  being  executed  were  defined.
1622              The  line  number is the line where the `function name' or `name
1623              ()' started.  In the case of an autoloaded  function   the  line
1624              number is reported as zero.  The format of each element is file‐
1625              name:lineno.
1626
1627              For functions autoloaded from a file in native zsh format, where
1628              only  the  body of the function occurs in the file, or for files
1629              that have been executed by the source or `.' builtins, the trace
1630              information is shown as filename:0, since the entire file is the
1631              definition.  The source file name is  resolved  to  an  absolute
1632              path  when  the  function  is loaded or the path to it otherwise
1633              resolved.
1634
1635              Most users will be interested in the information  in  the  func‐
1636              filetrace array instead.
1637
1638       funcstack
1639              This  array  contains the names of the functions, sourced files,
1640              and (if EVAL_LINENO is set) eval commands. currently being  exe‐
1641              cuted.  The  first element is the name of the function using the
1642              parameter.
1643
1644              The standard shell array zsh_eval_context can be used to  deter‐
1645              mine  the  type of shell construct being executed at each depth:
1646              note, however, that is in the  opposite  order,  with  the  most
1647              recent item last, and it is more detailed, for example including
1648              an entry for toplevel, the main shell code being executed either
1649              interactively  or  from a script, which is not present in $func‐
1650              stack.
1651
1652       functrace
1653              This array contains the names and line numbers  of  the  callers
1654              corresponding  to  the  functions currently being executed.  The
1655              format of each element is name:lineno.  Callers are  also  shown
1656              for  sourced  files; the caller is the point where the source or
1657              `.' command was executed.
1658

THE ZSH/PCRE MODULE

1660       The zsh/pcre module makes some commands available as builtins:
1661
1662       pcre_compile [ -aimxs ] PCRE
1663              Compiles a perl-compatible regular expression.
1664
1665              Option -a will force the pattern to be anchored.  Option -i will
1666              compile  a  case-insensitive  pattern.  Option -m will compile a
1667              multi-line pattern; that is, ^ and $ will match newlines  within
1668              the  pattern.   Option  -x  will  compile  an  extended pattern,
1669              wherein whitespace and # comments are ignored.  Option -s  makes
1670              the dot metacharacter match all characters, including those that
1671              indicate newline.
1672
1673       pcre_study
1674              Studies the previously-compiled PCRE which may result in  faster
1675              matching.
1676
1677       pcre_match [ -v var ] [ -a arr ] [ -n offset ] [ -b ] string
1678              Returns  successfully  if string matches the previously-compiled
1679              PCRE.
1680
1681              Upon successful match, if  the  expression  captures  substrings
1682              within parentheses, pcre_match will set the array match to those
1683              substrings, unless the -a option is given, in which case it will
1684              set the array arr.  Similarly, the variable MATCH will be set to
1685              the entire matched portion of the string, unless the  -v  option
1686              is  given, in which case the variable var will be set.  No vari‐
1687              ables are altered if there is no successful match.  A -n  option
1688              starts  searching  for  a match from the byte offset position in
1689              string.  If the -b option is given, the variable  ZPCRE_OP  will
1690              be  set  to  an offset pair string, representing the byte offset
1691              positions of the entire matched portion within the string.   For
1692              example,  a  ZPCRE_OP  set to "32 45" indicates that the matched
1693              portion began on byte offset 32 and ended  on  byte  offset  44.
1694              Here, byte offset position 45 is the position directly after the
1695              matched portion.  Keep in mind that the byte position isn't nec‐
1696              essarily  the  same as the character position when UTF-8 charac‐
1697              ters are involved.  Consequently, the byte offset positions  are
1698              only to be relied on in the context of using them for subsequent
1699              searches on string, using an offset position as an  argument  to
1700              the  -n  option.  This is mostly used to implement the "find all
1701              non-overlapping matches" functionality.
1702
1703              A simple example of "find all non-overlapping matches":
1704
1705                     string="The following zip codes: 78884 90210 99513"
1706                     pcre_compile -m "\d{5}"
1707                     accum=()
1708                     pcre_match -b -- $string
1709                     while [[ $? -eq 0 ]] do
1710                         b=($=ZPCRE_OP)
1711                         accum+=$MATCH
1712                         pcre_match -b -n $b[2] -- $string
1713                     done
1714                     print -l $accum
1715
1716       The zsh/pcre module makes available the following test condition:
1717
1718       expr -pcre-match pcre
1719              Matches a string against a perl-compatible regular expression.
1720
1721              For example,
1722
1723                     [[ "$text" -pcre-match ^d+$ ]] &&
1724                     print text variable contains only "d's".
1725
1726              If the REMATCH_PCRE option is set, the =~ operator is equivalent
1727              to  -pcre-match, and the NO_CASE_MATCH option may be used.  Note
1728              that NO_CASE_MATCH never  applies  to  the  pcre_match  builtin,
1729              instead use the -i switch of pcre_compile.
1730

THE ZSH/PARAM/PRIVATE MODULE

1732       The  zsh/param/private  module is used to create parameters whose scope
1733       is limited to the current function body, and  not  to  other  functions
1734       called by the current function.
1735
1736       This module provides a single autoloaded builtin:
1737
1738       private [ {+|-}AHUahlprtux ] [ {+|-}EFLRZi [ n ] ] [ name[=value] ... ]
1739              The  private  builtin accepts all the same options and arguments
1740              as local (zshbuiltins(1)) except  for  the  `-T'  option.   Tied
1741              parameters may not be made private.
1742
1743              If  used  at  the  top level (outside a function scope), private
1744              creates a normal parameter in the  same  manner  as  declare  or
1745              typeset.   A warning about this is printed if WARN_CREATE_GLOBAL
1746              is set (zshoptions(1)).  Used inside a function  scope,  private
1747              creates  a  local  parameter similar to one declared with local,
1748              except having special properties noted below.
1749
1750              Special parameters which expose  or  manipulate  internal  shell
1751              state,  such  as  ARGC,  argv,  COLUMNS,  LINES, UID, EUID, IFS,
1752              PROMPT, RANDOM, SECONDS, etc., cannot be made private unless the
1753              `-h'  option  is used to hide the special meaning of the parame‐
1754              ter.  This may change in the future.
1755
1756       As with other typeset equivalents, private is  both  a  builtin  and  a
1757       reserved  word,  so arrays may be assigned with parenthesized word list
1758       name=(value...) syntax.  However, the reserved word  `private'  is  not
1759       available until zsh/param/private is loaded, so care must be taken with
1760       order of execution and parsing for function definitions which use  pri‐
1761       vate.   To compensate for this, the module also adds the option `-P' to
1762       the `local' builtin to declare private parameters.
1763
1764       For example, this construction fails if zsh/param/private has  not  yet
1765       been loaded when `bad_declaration' is defined:
1766              bad_declaration() {
1767                zmodload zsh/param/private
1768                private array=( one two three )
1769              }
1770
1771       This  construction  works  because  local is already a keyword, and the
1772       module is loaded before the statement is executed:
1773              good_declaration() {
1774                zmodload zsh/param/private
1775                local -P array=( one two three )
1776              }
1777
1778       The following is usable in scripts but may have trouble with autoload:
1779              zmodload zsh/param/private
1780              iffy_declaration() {
1781                private array=( one two three )
1782              }
1783
1784       The private builtin may always be used with scalar assignments and  for
1785       declarations without assignments.
1786
1787       Parameters declared with private have the following properties:
1788
1789       ·      Within  the  function  body  where it is declared, the parameter
1790              behaves as a local, except as noted above for  tied  or  special
1791              parameters.
1792
1793       ·      The  type  of  a parameter declared private cannot be changed in
1794              the scope where it was declared, even if the parameter is unset.
1795              Thus an array cannot be assigned to a private scalar, etc.
1796
1797       ·      Within  any other function called by the declaring function, the
1798              private parameter does NOT hide other  parameters  of  the  same
1799              name, so for example a global parameter of the same name is vis‐
1800              ible and may be assigned  or  unset.   This  includes  calls  to
1801              anonymous  functions,  although  that  may  also  change  in the
1802              future.
1803
1804       ·      An exported private remains in the environment of  inner  scopes
1805              but appears unset for the current shell in those scopes.  Gener‐
1806              ally, exporting private parameters should be avoided.
1807
1808       Note that this differs from the static scope defined by  compiled  lan‐
1809       guages derived from C, in that the a new call to the same function cre‐
1810       ates a new scope, i.e., the parameter is still associated with the call
1811       stack  rather  than  with the function definition.  It differs from ksh
1812       `typeset -S' because the syntax used to  define  the  function  has  no
1813       bearing on whether the parameter scope is respected.
1814

THE ZSH/REGEX MODULE

1816       The zsh/regex module makes available the following test condition:
1817
1818       expr -regex-match regex
1819              Matches  a  string  against a POSIX extended regular expression.
1820              On successful match, matched portion of the string will normally
1821              be  placed  in  the  MATCH variable.  If there are any capturing
1822              parentheses within the regex, then the match array variable will
1823              contain  those.   If the match is not successful, then the vari‐
1824              ables will not be altered.
1825
1826              For example,
1827
1828                     [[ alphabetical -regex-match ^a([^a]+)a([^a]+)a ]] &&
1829                     print -l $MATCH X $match
1830
1831              If the option REMATCH_PCRE is not set, then the =~ operator will
1832              automatically  load  this  module  as needed and will invoke the
1833              -regex-match operator.
1834
1835              If BASH_REMATCH is set, then the array BASH_REMATCH will be  set
1836              instead of MATCH and match.
1837

THE ZSH/SCHED MODULE

1839       The zsh/sched module makes available one builtin command and one param‐
1840       eter.
1841
1842       sched [-o] [+]hh:mm[:ss] command ...
1843       sched [-o] [+]seconds command ...
1844       sched [ -item ]
1845              Make an entry in the scheduled list of commands to execute.  The
1846              time  may  be specified in either absolute or relative time, and
1847              either as hours, minutes and (optionally) seconds separated by a
1848              colon,  or  seconds  alone.  An absolute number of seconds indi‐
1849              cates the time since the epoch (1970/01/01 00:00); this is  use‐
1850              ful in combination with the features in the zsh/datetime module,
1851              see the zsh/datetime module entry in zshmodules(1).
1852
1853              With no arguments, prints the list of  scheduled  commands.   If
1854              the  scheduled command has the -o flag set, this is shown at the
1855              start of the command.
1856
1857              With the argument `-item', removes the given item from the list.
1858              The  numbering of the list is continuous and entries are in time
1859              order, so the numbering can change when  entries  are  added  or
1860              deleted.
1861
1862              Commands  are  executed  either  immediately before a prompt, or
1863              while the shell's line editor is waiting for input.  In the lat‐
1864              ter case it is useful to be able to produce output that does not
1865              interfere with the line being edited.  Providing the  option  -o
1866              causes  the shell to clear the command line before the event and
1867              redraw it afterwards.  This should be used  with  any  scheduled
1868              event  that  produces  visible output to the terminal; it is not
1869              needed, for example, with output that updates a terminal  emula‐
1870              tor's title bar.
1871
1872              To  effect  changes to the editor buffer when an event executes,
1873              use the `zle' command with no arguments to test whether the edi‐
1874              tor is active, and if it is, then use `zle widget' to access the
1875              editor via the named widget.
1876
1877              The sched builtin is not made  available  by  default  when  the
1878              shell  starts in a mode emulating another shell.  It can be made
1879              available with the command `zmodload -F zsh/sched b:sched'.
1880
1881       zsh_scheduled_events
1882              A readonly array corresponding to the events  scheduled  by  the
1883              sched  builtin.  The indices of the array correspond to the num‐
1884              bers shown when sched is run with no  arguments  (provided  that
1885              the  KSH_ARRAYS option is not set).  The value of the array con‐
1886              sists of the scheduled time in seconds since the epoch (see  the
1887              section  `The zsh/datetime Module' for facilities for using this
1888              number), followed by a colon, followed by any options (which may
1889              be empty but will be preceded by a `-' otherwise), followed by a
1890              colon, followed by the command to be executed.
1891
1892              The sched builtin should be used for  manipulating  the  events.
1893              Note  that this will have an immediate effect on the contents of
1894              the array, so that indices may become invalid.
1895

THE ZSH/NET/SOCKET MODULE

1897       The zsh/net/socket module makes available one builtin command:
1898
1899       zsocket [ -altv ] [ -d fd ] [ args ]
1900              zsocket is implemented as a builtin to allow full use  of  shell
1901              command line editing, file I/O, and job control mechanisms.
1902
1903   Outbound Connections
1904       zsocket [ -v ] [ -d fd ] filename
1905              Open a new Unix domain connection to filename.  The shell param‐
1906              eter REPLY will be set to the file  descriptor  associated  with
1907              that  connection.   Currently,  only stream connections are sup‐
1908              ported.
1909
1910              If -d is specified, its argument will be  taken  as  the  target
1911              file descriptor for the connection.
1912
1913              In order to elicit more verbose output, use -v.
1914
1915              File  descriptors can be closed with normal shell syntax when no
1916              longer needed, for example:
1917
1918                     exec {REPLY}>&-
1919
1920   Inbound Connections
1921       zsocket -l [ -v ] [ -d fd ] filename
1922              zsocket -l will open a socket listening on filename.  The  shell
1923              parameter  REPLY  will  be set to the file descriptor associated
1924              with that listener.
1925
1926              If -d is specified, its argument will be  taken  as  the  target
1927              file descriptor for the connection.
1928
1929              In order to elicit more verbose output, use -v.
1930
1931       zsocket -a [ -tv ] [ -d targetfd ] listenfd
1932              zsocket  -a  will  accept  an  incoming connection to the socket
1933              associated with listenfd.  The shell parameter REPLY will be set
1934              to the file descriptor associated with the inbound connection.
1935
1936              If  -d  is  specified,  its argument will be taken as the target
1937              file descriptor for the connection.
1938
1939              If -t is specified, zsocket will return if no  incoming  connec‐
1940              tion is pending.  Otherwise it will wait for one.
1941
1942              In order to elicit more verbose output, use -v.
1943

THE ZSH/STAT MODULE

1945       The  zsh/stat module makes available one builtin command under two pos‐
1946       sible names:
1947
1948       zstat [ -gnNolLtTrs ] [ -f fd ] [ -H hash ] [ -A array ] [ -F fmt ]
1949             [ +element ] [ file ... ]
1950       stat ...
1951              The command acts as a front end to the  stat  system  call  (see
1952              stat(2)).   The  same command is provided with two names; as the
1953              name stat is often used by an external command it is recommended
1954              that  only  the  zstat form of the command is used.  This can be
1955              arranged by loading the module with  the  command  `zmodload  -F
1956              zsh/stat b:zstat'.
1957
1958              If  the  stat  call  fails, the appropriate system error message
1959              printed and status 1 is returned.  The  fields  of  struct  stat
1960              give  information  about  the files provided as arguments to the
1961              command.  In addition to those available from the stat call,  an
1962              extra element `link' is provided.  These elements are:
1963
1964              device The number of the device on which the file resides.
1965
1966              inode  The  unique  number  of  the file on this device (`inode'
1967                     number).
1968
1969              mode   The mode of the file; that is, the file's type and access
1970                     permissions.   With  the -s option, this will be returned
1971                     as a string corresponding to the first column in the dis‐
1972                     play of the ls -l command.
1973
1974              nlink  The number of hard links to the file.
1975
1976              uid    The  user  ID  of  the  owner  of  the file.  With the -s
1977                     option, this is displayed as a user name.
1978
1979              gid    The group ID of the file.  With the -s  option,  this  is
1980                     displayed as a group name.
1981
1982              rdev   The  raw  device number.  This is only useful for special
1983                     devices.
1984
1985              size   The size of the file in bytes.
1986
1987              atime
1988              mtime
1989              ctime  The last access, modification and inode change  times  of
1990                     the  file,  respectively,  as the number of seconds since
1991                     midnight GMT on 1st January, 1970.  With the  -s  option,
1992                     these are printed as strings for the local time zone; the
1993                     format can be altered with the -F option, and with the -g
1994                     option the times are in GMT.
1995
1996              blksize
1997                     The number of bytes in one allocation block on the device
1998                     on which the file resides.
1999
2000              block  The number of disk blocks used by the file.
2001
2002              link   If the file is a link and the -L  option  is  in  effect,
2003                     this  contains  the name of the file linked to, otherwise
2004                     it is empty.  Note  that  if  this  element  is  selected
2005                     (``zstat  +link'')  then  the  -L option is automatically
2006                     used.
2007
2008              A particular element may be selected by including its name  pre‐
2009              ceded  by a `+' in the option list; only one element is allowed.
2010              The element may be shortened to any unique set of leading  char‐
2011              acters.  Otherwise, all elements will be shown for all files.
2012
2013              Options:
2014
2015              -A array
2016                     Instead  of  displaying  the  results on standard output,
2017                     assign them to an array,  one  struct  stat  element  per
2018                     array  element for each file in order.  In this case nei‐
2019                     ther the name of the element nor the name  of  the  files
2020                     appears  in array unless the -t or -n options were given,
2021                     respectively.  If -t is given, the element  name  appears
2022                     as  a  prefix  to the appropriate array element; if -n is
2023                     given, the file name appears as a separate array  element
2024                     preceding  all  the others.  Other formatting options are
2025                     respected.
2026
2027              -H hash
2028                     Similar to -A, but instead assign  the  values  to  hash.
2029                     The keys are the elements listed above.  If the -n option
2030                     is provided then the name of the file is included in  the
2031                     hash with key name.
2032
2033              -f fd  Use  the  file  on  file  descriptor  fd instead of named
2034                     files; no list of file names is allowed in this case.
2035
2036              -F fmt Supplies a strftime (see strftime(3)) string for the for‐
2037                     matting of the time elements.  The -s option is implied.
2038
2039              -g     Show  the  time  elements  in  the GMT time zone.  The -s
2040                     option is implied.
2041
2042              -l     List the names of the type elements (to  standard  output
2043                     or an array as appropriate) and return immediately; argu‐
2044                     ments, and options other than -A, are ignored.
2045
2046              -L     Perform an lstat (see lstat(2)) rather than a stat system
2047                     call.   In  this case, if the file is a link, information
2048                     about the link itself rather  than  the  target  file  is
2049                     returned.   This option is required to make the link ele‐
2050                     ment useful.  It's important to note  that  this  is  the
2051                     exact opposite from ls(1), etc.
2052
2053              -n     Always  show  the names of files.  Usually these are only
2054                     shown when output is to standard output and there is more
2055                     than one file in the list.
2056
2057              -N     Never show the names of files.
2058
2059              -o     If a raw file mode is printed, show it in octal, which is
2060                     more useful for human consumption  than  the  default  of
2061                     decimal.   A  leading  zero will be printed in this case.
2062                     Note that this does not affect whether a raw or formatted
2063                     file  mode is shown, which is controlled by the -r and -s
2064                     options, nor whether a mode is shown at all.
2065
2066              -r     Print raw data (the default format) alongside string data
2067                     (the  -s  format); the string data appears in parentheses
2068                     after the raw data.
2069
2070              -s     Print mode, uid, gid  and  the  three  time  elements  as
2071                     strings  instead  of numbers.  In each case the format is
2072                     like that of ls -l.
2073
2074              -t     Always show the type names for  the  elements  of  struct
2075                     stat.   Usually  these  are  only shown when output is to
2076                     standard  output  and  no  individual  element  has  been
2077                     selected.
2078
2079              -T     Never show the type names of the struct stat elements.
2080

THE ZSH/SYSTEM MODULE

2082       The  zsh/system  module  makes  available  various builtin commands and
2083       parameters.
2084
2085   Builtins
2086       syserror [ -e errvar ] [ -p prefix ] [ errno | errname ]
2087              This command prints out the error message associated with errno,
2088              a system error number, followed by a newline to standard error.
2089
2090              Instead of the error number, a name errname, for example ENOENT,
2091              may be used.  The set of names is the same as  the  contents  of
2092              the array errnos, see below.
2093
2094              If  the  string  prefix  is given, it is printed in front of the
2095              error message, with no intervening space.
2096
2097              If errvar is supplied, the entire message, without a newline, is
2098              assigned to the parameter names errvar and nothing is output.
2099
2100              A  return  status  of  0  indicates the message was successfully
2101              printed (although it may not be useful if the error  number  was
2102              out  of  the  system's range), a return status of 1 indicates an
2103              error in the parameters, and a return status of 2 indicates  the
2104              error name was not recognised (no message is printed for this).
2105
2106
2107       sysopen [ -arw ] [ -m permissions ] [ -o options ]
2108               -u fd file
2109              This  command  opens  a  file.  The -r, -w and -a flags indicate
2110              whether the file should  be  opened  for  reading,  writing  and
2111              appending,  respectively.  The -m option allows the initial per‐
2112              missions to use when creating a file to be  specified  in  octal
2113              form.   The  file  descriptor  is  specified  with -u. Either an
2114              explicit file descriptor in the range 0 to 9 can be specified or
2115              a variable name can be given to which the file descriptor number
2116              will be assigned.
2117
2118              The -o option allows various system specific options to be spec‐
2119              ified as a comma-separated list. The following is a list of pos‐
2120              sible options. Note that, depending on the system, some may  not
2121              be available.
2122              cloexec
2123                     mark file to be closed when other programs are executed
2124
2125              create
2126              creat  create file if it does not exist
2127
2128              excl   create file, error if it already exists
2129
2130              noatime
2131                     suppress updating of the file atime
2132
2133              nofollow
2134                     fail if file is a symbolic link
2135
2136              sync   request  that  writes wait until data has been physically
2137                     written
2138
2139              truncate
2140              trunc  truncate file to size 0
2141
2142              To close the file, use one of the following:
2143
2144                     exec {fd}<&-
2145                     exec {fd}>&-
2146
2147
2148       sysread [ -c countvar ] [ -i infd ] [ -o outfd ]
2149               [ -s bufsize ] [ -t timeout ] [ param ]
2150              Perform a single system read from file descriptor infd, or  zero
2151              if that is not given.  The result of the read is stored in param
2152              or REPLY if that is not given.  If countvar is given, the number
2153              of bytes read is assigned to the parameter named by countvar.
2154
2155              The  maximum  number of bytes read is bufsize or 8192 if that is
2156              not given, however the command returns as soon as any number  of
2157              bytes was successfully read.
2158
2159              If  timeout  is  given, it specifies a timeout in seconds, which
2160              may be zero to poll the file descriptor.  This is handled by the
2161              poll  system call if available, otherwise the select system call
2162              if available.
2163
2164              If outfd is given, an attempt is made to  write  all  the  bytes
2165              just  read to the file descriptor outfd.  If this fails, because
2166              of a system error other than EINTR or because of an internal zsh
2167              error  during  an  interrupt, the bytes read but not written are
2168              stored in the parameter named by param if supplied  (no  default
2169              is  used  in  this  case),  and the number of bytes read but not
2170              written is stored in the parameter named by countvar if that  is
2171              supplied.  If it was successful, countvar contains the full num‐
2172              ber of bytes transferred, as usual, and param is not set.
2173
2174              The error EINTR (interrupted system call) is handled  internally
2175              so  that  shell  interrupts  are transparent to the caller.  Any
2176              other error causes a return.
2177
2178              The possible return statuses are
2179              0      At least one byte of data was successfully read  and,  if
2180                     appropriate, written.
2181
2182              1      There  was  an  error  in  the parameters to the command.
2183                     This is the only error for which a message is printed  to
2184                     standard error.
2185
2186              2      There  was  an error on the read, or on polling the input
2187                     file descriptor for a timeout.  The parameter ERRNO gives
2188                     the error.
2189
2190              3      Data were successfully read, but there was an error writ‐
2191                     ing them to outfd.  The parameter ERRNO gives the error.
2192
2193              4      The attempt to read timed out.  Note this  does  not  set
2194                     ERRNO as this is not a system error.
2195
2196              5      No system error occurred, but zero bytes were read.  This
2197                     usually indicates end of file.  The  parameters  are  set
2198                     according  to  the  usual  rules;  no  write  to outfd is
2199                     attempted.
2200
2201       sysseek [ -u fd ] [ -w start|end|current ] offset
2202              The current file position at which future reads and writes  will
2203              take  place is adjusted to the specified byte offset. The offset
2204              is evaluated as a math expression. The -u option allows the file
2205              descriptor  to  be specified. By default the offset is specified
2206              relative to the start or the file but, with the -w option, it is
2207              possible  to  specify  that the offset should be relative to the
2208              current position or the end of the file.
2209
2210       syswrite [ -c countvar ] [ -o outfd ] data
2211              The data (a single string of bytes)  are  written  to  the  file
2212              descriptor  outfd,  or  1  if that is not given, using the write
2213              system call.  Multiple write operations may be used if the first
2214              does not write all the data.
2215
2216              If  countvar  is  given, the number of byte written is stored in
2217              the parameter named by countvar; this may not be the full length
2218              of data if an error occurred.
2219
2220              The  error EINTR (interrupted system call) is handled internally
2221              by retrying; otherwise an error causes the  command  to  return.
2222              For  example, if the file descriptor is set to non-blocking out‐
2223              put, an error EAGAIN (on some systems, EWOULDBLOCK)  may  result
2224              in the command returning early.
2225
2226              The  return  status  may be 0 for success, 1 for an error in the
2227              parameters to the command, or 2 for an error on  the  write;  no
2228              error  message  is  printed  in the last case, but the parameter
2229              ERRNO will reflect the error that occurred.
2230
2231       zsystem flock [ -t timeout ] [ -f var ] [-er] file
2232       zsystem flock -u fd_expr
2233              The builtin zsystem's subcommand flock  performs  advisory  file
2234              locking  (via the fcntl(2) system call) over the entire contents
2235              of the given file.  This form of locking requires the  processes
2236              accessing the file to cooperate; its most obvious use is between
2237              two instances of the shell itself.
2238
2239              In the first form the named file, which must already  exist,  is
2240              locked  by  opening a file descriptor to the file and applying a
2241              lock to the file descriptor.  The lock terminates when the shell
2242              process  that created the lock exits; it is therefore often con‐
2243              venient to create file locks within subshells, since the lock is
2244              automatically  released  when  the  subshell exits.  Status 0 is
2245              returned if the lock succeeds, else status 1.
2246
2247              In the second form the file descriptor given by  the  arithmetic
2248              expression  fd_expr  is  closed,  releasing  a  lock.   The file
2249              descriptor can be queried by using the `-f var' form during  the
2250              lock; on a successful lock, the shell variable var is set to the
2251              file descriptor used for locking.  The lock will be released  if
2252              the  file  descriptor  is closed by any other means, for example
2253              using `exec {var}>&-'; however, the form described here performs
2254              a safety check that the file descriptor is in use for file lock‐
2255              ing.
2256
2257              By default the shell waits indefinitely for the lock to succeed.
2258              The  option  -t timeout specifies a timeout for the lock in sec‐
2259              onds; currently this must be an integer.  The shell will attempt
2260              to  lock  the  file  once  a  second during this period.  If the
2261              attempt times out, status 2 is returned.
2262
2263              If the option -e is given, the file descriptor for the  lock  is
2264              preserved  when the shell uses exec to start a new process; oth‐
2265              erwise it is closed at that point and the lock released.
2266
2267              If the option -r is given, the lock is only for reading,  other‐
2268              wise  it  is  for  reading  and writing.  The file descriptor is
2269              opened accordingly.
2270
2271       zsystem supports subcommand
2272              The builtin zsystem's subcommand supports tests whether a  given
2273              subcommand is supported.  It returns status 0 if so, else status
2274              1.  It operates silently unless there was a syntax  error  (i.e.
2275              the  wrong  number  of  arguments),  in which case status 255 is
2276              returned.  Status 1 can indicate one of two things:   subcommand
2277              is  known  but not supported by the current operating system, or
2278              subcommand is not known (possibly because this is an older  ver‐
2279              sion of the shell before it was implemented).
2280
2281   Math Functions
2282       systell(fd)
2283              The  systell math function returns the current file position for
2284              the file descriptor passed as an argument.
2285
2286   Parameters
2287       errnos A readonly array of the names of errors defined on  the  system.
2288              These  are typically macros defined in C by including the system
2289              header file errno.h.  The  index  of  each  name  (assuming  the
2290              option  KSH_ARRAYS  is  unset)  corresponds to the error number.
2291              Error numbers num before the last known error which have no name
2292              are given the name Enum in the array.
2293
2294              Note that aliases for errors are not handled; only the canonical
2295              name is used.
2296
2297       sysparams
2298              A readonly associative array.  The keys are:
2299
2300              pid    Returns the process ID of the current  process,  even  in
2301                     subshells.   Compare  $$, which returns the process ID of
2302                     the main shell process.
2303
2304              ppid   Returns the process ID  of  the  parent  of  the  current
2305                     process, even in subshells.  Compare $PPID, which returns
2306                     the process ID of the parent of the main shell process.
2307

THE ZSH/NET/TCP MODULE

2309       The zsh/net/tcp module makes available one builtin command:
2310
2311       ztcp [ -acflLtv ] [ -d fd ] [ args ]
2312              ztcp is implemented as a builtin to allow full use of shell com‐
2313              mand line editing, file I/O, and job control mechanisms.
2314
2315              If  ztcp  is run with no options, it will output the contents of
2316              its session table.
2317
2318              If it is run with only the option -L, it will  output  the  con‐
2319              tents  of  the  session table in a format suitable for automatic
2320              parsing.  The option is ignored if given with a command to  open
2321              or  close a session.  The output consists of a set of lines, one
2322              per session, each containing the following elements separated by
2323              spaces:
2324
2325              File descriptor
2326                     The  file descriptor in use for the connection.  For nor‐
2327                     mal inbound (I) and outbound (O) connections this may  be
2328                     read and written by the usual shell mechanisms.  However,
2329                     it should only be close with `ztcp -c'.
2330
2331              Connection type
2332                     A letter indicating how the session was created:
2333
2334                     Z      A session created with the zftp command.
2335
2336                     L      A connection opened for listening with `ztcp -l'.
2337
2338                     I      An inbound connection accepted with `ztcp -a'.
2339
2340                     O      An outbound connection  created  with  `ztcp  host
2341                            ...'.
2342
2343              The local host
2344                     This  is  usually  set  to  an all-zero IP address as the
2345                     address of the localhost is irrelevant.
2346
2347              The local port
2348                     This is likely to be zero unless the  connection  is  for
2349                     listening.
2350
2351              The remote host
2352                     This  is  the fully qualified domain name of the peer, if
2353                     available, else an IP address.   It  is  an  all-zero  IP
2354                     address for a session opened for listening.
2355
2356              The remote port
2357                     This is zero for a connection opened for listening.
2358
2359   Outbound Connections
2360       ztcp [ -v ] [ -d fd ] host [ port ]
2361              Open  a  new TCP connection to host.  If the port is omitted, it
2362              will default to port 23.  The connection will be  added  to  the
2363              session  table  and the shell parameter REPLY will be set to the
2364              file descriptor associated with that connection.
2365
2366              If -d is specified, its argument will be  taken  as  the  target
2367              file descriptor for the connection.
2368
2369              In order to elicit more verbose output, use -v.
2370
2371   Inbound Connections
2372       ztcp -l [ -v ] [ -d fd ] port
2373              ztcp  -l  will  open a socket listening on TCP port.  The socket
2374              will be added to the session table and the shell parameter REPLY
2375              will  be  set  to  the file descriptor associated with that lis‐
2376              tener.
2377
2378              If -d is specified, its argument will be  taken  as  the  target
2379              file descriptor for the connection.
2380
2381              In order to elicit more verbose output, use -v.
2382
2383       ztcp -a [ -tv ] [ -d targetfd ] listenfd
2384              ztcp  -a  will accept an incoming connection to the port associ‐
2385              ated with listenfd.  The connection will be added to the session
2386              table  and  the  shell  parameter  REPLY will be set to the file
2387              descriptor associated with the inbound connection.
2388
2389              If -d is specified, its argument will be  taken  as  the  target
2390              file descriptor for the connection.
2391
2392              If  -t  is specified, ztcp will return if no incoming connection
2393              is pending.  Otherwise it will wait for one.
2394
2395              In order to elicit more verbose output, use -v.
2396
2397   Closing Connections
2398       ztcp -cf [ -v ] [ fd ]
2399       ztcp -c [ -v ] [ fd ]
2400              ztcp -c will close the socket associated with  fd.   The  socket
2401              will be removed from the session table.  If fd is not specified,
2402              ztcp will close everything in the session table.
2403
2404              Normally, sockets registered by zftp (see zshmodules(1) ) cannot
2405              be closed this way.  In order to force such a socket closed, use
2406              -f.
2407
2408              In order to elicit more verbose output, use -v.
2409
2410   Example
2411       Here is how to create a TCP connection between two  instances  of  zsh.
2412       We  need  to  pick  an unassigned port; here we use the randomly chosen
2413       5123.
2414
2415       On host1,
2416              zmodload zsh/net/tcp
2417              ztcp -l 5123
2418              listenfd=$REPLY
2419              ztcp -a $listenfd
2420              fd=$REPLY
2421       The second from last command blocks until there is an incoming  connec‐
2422       tion.
2423
2424       Now  create  a connection from host2 (which may, of course, be the same
2425       machine):
2426              zmodload zsh/net/tcp
2427              ztcp host1 5123
2428              fd=$REPLY
2429
2430       Now on each host, $fd contains a file descriptor  for  talking  to  the
2431       other.  For example, on host1:
2432              print This is a message >&$fd
2433       and on host2:
2434              read -r line <&$fd; print -r - $line
2435       prints `This is a message'.
2436
2437       To tidy up, on host1:
2438              ztcp -c $listenfd
2439              ztcp -c $fd
2440       and on host2
2441              ztcp -c $fd
2442

THE ZSH/TERMCAP MODULE

2444       The zsh/termcap module makes available one builtin command:
2445
2446       echotc cap [ arg ... ]
2447              Output  the  termcap  value corresponding to the capability cap,
2448              with optional arguments.
2449
2450       The zsh/termcap module makes available one parameter:
2451
2452       termcap
2453              An associative array that maps termcap capability codes to their
2454              values.
2455

THE ZSH/TERMINFO MODULE

2457       The zsh/terminfo module makes available one builtin command:
2458
2459       echoti cap [ arg ]
2460              Output  the  terminfo value corresponding to the capability cap,
2461              instantiated with arg if applicable.
2462
2463       The zsh/terminfo module makes available one parameter:
2464
2465       terminfo
2466              An associative array that  maps  terminfo  capability  names  to
2467              their values.
2468

THE ZSH/ZFTP MODULE

2470       The zsh/zftp module makes available one builtin command:
2471
2472       zftp subcommand [ args ]
2473              The  zsh/zftp  module  is a client for FTP (file transfer proto‐
2474              col).  It is implemented as a builtin to allow full use of shell
2475              command  line  editing,  file  I/O,  and job control mechanisms.
2476              Often, users will access it via shell functions providing a more
2477              powerful  interface; a set is provided with the zsh distribution
2478              and is described in zshzftpsys(1).  However, the zftp command is
2479              entirely usable in its own right.
2480
2481              All  commands  consist  of the command name zftp followed by the
2482              name of a subcommand.  These are listed below.  The return  sta‐
2483              tus  of  each  subcommand  is supposed to reflect the success or
2484              failure of the remote operation.  See a description of the vari‐
2485              able ZFTP_VERBOSE for more information on how responses from the
2486              server may be printed.
2487
2488   Subcommands
2489       open host[:port] [ user [ password [ account ] ] ]
2490              Open a new FTP session to host, which  may  be  the  name  of  a
2491              TCP/IP  connected host or an IP number in the standard dot nota‐
2492              tion.  If the argument is in the form host:port, open a  connec‐
2493              tion to TCP port port instead of the standard FTP port 21.  This
2494              may be the name of a TCP service or a number:  see the  descrip‐
2495              tion of ZFTP_PORT below for more information.
2496
2497              If  IPv6  addresses in colon format are used, the host should be
2498              surrounded by quoted square brackets to distinguish it from  the
2499              port, for example '[fe80::203:baff:fe02:8b56]'.  For consistency
2500              this is allowed with all forms of host.
2501
2502              Remaining arguments are passed to the  login  subcommand.   Note
2503              that  if  no  arguments  beyond host are supplied, open will not
2504              automatically call login.  If no arguments at all are  supplied,
2505              open will use the parameters set by the params subcommand.
2506
2507              After   a   successful  open,  the  shell  variables  ZFTP_HOST,
2508              ZFTP_PORT, ZFTP_IP and ZFTP_SYSTEM  are  available;  see  `Vari‐
2509              ables' below.
2510
2511       login [ name [ password [ account ] ] ]
2512       user [ name [ password [ account ] ] ]
2513              Login  the  user name with parameters password and account.  Any
2514              of the parameters can be omitted, and will be read from standard
2515              input if needed (name is always needed).  If standard input is a
2516              terminal, a prompt for each one  will  be  printed  on  standard
2517              error and password will not be echoed.  If any of the parameters
2518              are not used, a warning message is printed.
2519
2520              After  a  successful  login,  the  shell  variables   ZFTP_USER,
2521              ZFTP_ACCOUNT and ZFTP_PWD are available; see `Variables' below.
2522
2523              This  command may be re-issued when a user is already logged in,
2524              and the server will first be reinitialized for a new user.
2525
2526       params [ host [ user [ password [ account ] ] ] ]
2527       params -
2528              Store the given parameters for a  later  open  command  with  no
2529              arguments.   Only those given on the command line will be remem‐
2530              bered.  If no arguments are given, the parameters currently  set
2531              are  printed,  although  the  password  will appear as a line of
2532              stars; the return status is one if no parameters were set,  zero
2533              otherwise.
2534
2535              Any  of the parameters may be specified as a `?', which may need
2536              to be quoted to protect it from shell expansion.  In this  case,
2537              the  appropriate  parameter  will be read from stdin as with the
2538              login subcommand, including special handling  of  password.   If
2539              the  `?' is followed by a string, that is used as the prompt for
2540              reading the parameter instead of the default message (any neces‐
2541              sary punctuation and whitespace should be included at the end of
2542              the prompt).  The first letter of the parameter  (only)  may  be
2543              quoted  with  a `\'; hence an argument "\\$word" guarantees that
2544              the string from the shell parameter $word will be treated liter‐
2545              ally, whether or not it begins with a `?'.
2546
2547              If  instead  a  single `-' is given, the existing parameters, if
2548              any, are deleted.  In that case, calling open with no  arguments
2549              will cause an error.
2550
2551              The  list of parameters is not deleted after a close, however it
2552              will be deleted if the zsh/zftp module is unloaded.
2553
2554              For example,
2555
2556                     zftp params ftp.elsewhere.xx juser '?Password for juser: '
2557
2558              will store the host ftp.elsewhere.xx and the user juser and then
2559              prompt  the  user  for the corresponding password with the given
2560              prompt.
2561
2562       test   Test the connection; if the server  has  reported  that  it  has
2563              closed the connection (maybe due to a timeout), return status 2;
2564              if no connection was open anyway, return status 1;  else  return
2565              status  0.   The  test subcommand is silent, apart from messages
2566              printed by the $ZFTP_VERBOSE mechanism, or error messages if the
2567              connection closes.  There is no network overhead for this test.
2568
2569              The  test is only supported on systems with either the select(2)
2570              or poll(2) system calls; otherwise the message `not supported on
2571              this system' is printed instead.
2572
2573              The test subcommand will automatically be called at the start of
2574              any other subcommand for the current session when  a  connection
2575              is open.
2576
2577       cd directory
2578              Change the remote directory to directory.  Also alters the shell
2579              variable ZFTP_PWD.
2580
2581       cdup   Change the remote directory to the one higher in  the  directory
2582              tree.  Note that cd .. will also work correctly on non-UNIX sys‐
2583              tems.
2584
2585       dir [ arg ... ]
2586              Give a (verbose) listing of the remote directory.  The args  are
2587              passed directly to the server. The command's behaviour is imple‐
2588              mentation dependent, but a UNIX server will typically  interpret
2589              args as arguments to the ls command and with no arguments return
2590              the result of `ls -l'. The directory is listed to standard  out‐
2591              put.
2592
2593       ls [ arg ... ]
2594              Give  a  (short)  listing of the remote directory.  With no arg,
2595              produces a raw list of the files in the directory, one per line.
2596              Otherwise,  up to vagaries of the server implementation, behaves
2597              similar to dir.
2598
2599       type [ type ]
2600              Change the type for the transfer to type, or print  the  current
2601              type if type is absent.  The allowed values are `A' (ASCII), `I'
2602              (Image, i.e. binary), or `B' (a synonym for `I').
2603
2604              The FTP default for a transfer is ASCII.  However, if zftp finds
2605              that  the remote host is a UNIX machine with 8-bit byes, it will
2606              automatically switch to using binary  for  file  transfers  upon
2607              open.  This can subsequently be overridden.
2608
2609              The  transfer type is only passed to the remote host when a data
2610              connection is established;  this  command  involves  no  network
2611              overhead.
2612
2613       ascii  The same as type A.
2614
2615       binary The same as type I.
2616
2617       mode [ S | B ]
2618              Set  the  mode  type to stream (S) or block (B).  Stream mode is
2619              the default; block mode is not widely supported.
2620
2621       remote file ...
2622       local [ file ... ]
2623              Print the size and last modification time of the remote or local
2624              files.   If there is more than one item on the list, the name of
2625              the file is printed first.  The first number is the  file  size,
2626              the second is the last modification time of the file in the for‐
2627              mat CCYYMMDDhhmmSS consisting of year, month, date,  hour,  min‐
2628              utes  and  seconds in GMT.  Note that this format, including the
2629              length, is guaranteed, so that time strings can be directly com‐
2630              pared  via  the [[ builtin's < and > operators, even if they are
2631              too long to be represented as integers.
2632
2633              Not all servers support the commands for retrieving this  infor‐
2634              mation.  In that case, the remote command will print nothing and
2635              return status 2, compared with status 1 for a file not found.
2636
2637              The local command (but not remote) may be  used  with  no  argu‐
2638              ments,  in  which case the information comes from examining file
2639              descriptor zero.  This is the same file as seen by a put command
2640              with no further redirection.
2641
2642       get file ...
2643              Retrieve all files from the server, concatenating them and send‐
2644              ing them to standard output.
2645
2646       put file ...
2647              For each file, read a file from standard input and send that  to
2648              the remote host with the given name.
2649
2650       append file ...
2651              As  put, but if the remote file already exists, data is appended
2652              to it instead of overwriting it.
2653
2654       getat file point
2655       putat file point
2656       appendat file point
2657              Versions of get, put and append which will start the transfer at
2658              the  given point in the remote file.  This is useful for append‐
2659              ing to an incomplete local file.  However, note that this  abil‐
2660              ity  is  not  universally supported by servers (and is not quite
2661              the behaviour specified by the standard).
2662
2663       delete file ...
2664              Delete the list of files on the server.
2665
2666       mkdir directory
2667              Create a new directory directory on the server.
2668
2669       rmdir directory
2670              Delete the directory directory  on the server.
2671
2672       rename old-name new-name
2673              Rename file old-name to new-name on the server.
2674
2675       site arg ...
2676              Send a host-specific command to the server.  You  will  probably
2677              only need this if instructed by the server to use it.
2678
2679       quote arg ...
2680              Send  the raw FTP command sequence to the server.  You should be
2681              familiar with the FTP command set as defined  in  RFC959  before
2682              doing  this.   Useful  commands may include STAT and HELP.  Note
2683              also the mechanism for returning messages as described  for  the
2684              variable  ZFTP_VERBOSE  below,  in  particular that all messages
2685              from the control connection are sent to standard error.
2686
2687       close
2688       quit   Close the current data connection.  This unsets the shell param‐
2689              eters  ZFTP_HOST,  ZFTP_PORT,  ZFTP_IP,  ZFTP_SYSTEM, ZFTP_USER,
2690              ZFTP_ACCOUNT, ZFTP_PWD, ZFTP_TYPE and ZFTP_MODE.
2691
2692       session [ sessname ]
2693              Allows multiple FTP sessions to be used at once.   The  name  of
2694              the  session  is  an arbitrary string of characters; the default
2695              session is called `default'.  If this command is called  without
2696              an  argument,  it  will  list  all the current sessions; with an
2697              argument, it will either switch to the existing  session  called
2698              sessname, or create a new session of that name.
2699
2700              Each  session remembers the status of the connection, the set of
2701              connection-specific shell parameters (the same set as are  unset
2702              when a connection closes, as given in the description of close),
2703              and any user parameters specified with  the  params  subcommand.
2704              Changing  to  a previous session restores those values; changing
2705              to a new session initialises them in the same way as if zftp had
2706              just  been  loaded.  The name of the current session is given by
2707              the parameter ZFTP_SESSION.
2708
2709       rmsession [ sessname ]
2710              Delete a session; if a name is not given, the current session is
2711              deleted.  If the current session is deleted, the earliest exist‐
2712              ing session becomes the new current session, otherwise the  cur‐
2713              rent  session  is  not changed.  If the session being deleted is
2714              the only one, a new session  called  `default'  is  created  and
2715              becomes  the  current  session;  note that this is a new session
2716              even if the session being deleted is also called  `default'.  It
2717              is  recommended  that  sessions  not be deleted while background
2718              commands which use zftp are still active.
2719
2720   Parameters
2721       The following shell parameters are used by  zftp.   Currently  none  of
2722       them are special.
2723
2724       ZFTP_TMOUT
2725              Integer.  The time in seconds to wait for a network operation to
2726              complete before returning an error.  If this is not set when the
2727              module  is  loaded,  it  will  be given the default value 60.  A
2728              value of zero turns off timeouts.  If a timeout  occurs  on  the
2729              control  connection  it  will  be closed.  Use a larger value if
2730              this occurs too frequently.
2731
2732       ZFTP_IP
2733              Readonly.  The IP address of the current connection in dot nota‐
2734              tion.
2735
2736       ZFTP_HOST
2737              Readonly.   The  hostname  of the current remote server.  If the
2738              host was  opened  as  an  IP  number,  ZFTP_HOST  contains  that
2739              instead;  this  saves the overhead for a name lookup, as IP num‐
2740              bers are most commonly used when a nameserver is unavailable.
2741
2742       ZFTP_PORT
2743              Readonly.  The number of the remote TCP port to which  the  con‐
2744              nection  is open (even if the port was originally specified as a
2745              named service).  Usually this is the standard FTP port, 21.
2746
2747              In the unlikely event that your system does not have the  appro‐
2748              priate conversion functions, this appears in network byte order.
2749              If your system is little-endian, the port then consists  of  two
2750              swapped  bytes  and  the standard port will be reported as 5376.
2751              In that case, numeric ports passed to zftp open will  also  need
2752              to be in this format.
2753
2754       ZFTP_SYSTEM
2755              Readonly.   The  system  type  string  returned by the server in
2756              response to an FTP SYST request.  The most interesting case is a
2757              string beginning "UNIX Type: L8", which ensures maximum compati‐
2758              bility with a local UNIX host.
2759
2760       ZFTP_TYPE
2761              Readonly.  The type to be used for data transfers ,  either  `A'
2762              or `I'.   Use the type subcommand to change this.
2763
2764       ZFTP_USER
2765              Readonly.  The username currently logged in, if any.
2766
2767       ZFTP_ACCOUNT
2768              Readonly.   The  account name of the current user, if any.  Most
2769              servers do not require an account name.
2770
2771       ZFTP_PWD
2772              Readonly.  The current directory on the server.
2773
2774       ZFTP_CODE
2775              Readonly.  The three digit code of the last FTP reply  from  the
2776              server as a string.  This can still be read after the connection
2777              is closed, and is not changed when the current session changes.
2778
2779       ZFTP_REPLY
2780              Readonly.  The last line of the last reply sent by  the  server.
2781              This  can  still  be read after the connection is closed, and is
2782              not changed when the current session changes.
2783
2784       ZFTP_SESSION
2785              Readonly.  The name of the current FTP session; see the descrip‐
2786              tion of the session subcommand.
2787
2788       ZFTP_PREFS
2789              A  string  of  preferences for altering aspects of zftp's behav‐
2790              iour.  Each preference is a single character.  The following are
2791              defined:
2792
2793              P      Passive:  attempt to make the remote server initiate data
2794                     transfers.  This is slightly more efficient than sendport
2795                     mode.   If  the letter S occurs later in the string, zftp
2796                     will use sendport mode if passive mode is not available.
2797
2798              S      Sendport:  initiate transfers by the  FTP  PORT  command.
2799                     If  this  occurs before any P in the string, passive mode
2800                     will never be attempted.
2801
2802              D      Dumb:  use only the bare minimum of FTP  commands.   This
2803                     prevents  the  variables  ZFTP_SYSTEM  and  ZFTP_PWD from
2804                     being set, and will mean all connections default to ASCII
2805                     type.   It  may prevent ZFTP_SIZE from being set during a
2806                     transfer if the server does  not  send  it  anyway  (many
2807                     servers do).
2808
2809              If  ZFTP_PREFS is not set when zftp is loaded, it will be set to
2810              a default of `PS', i.e. use passive mode if available, otherwise
2811              fall back to sendport mode.
2812
2813       ZFTP_VERBOSE
2814              A  string  of digits between 0 and 5 inclusive, specifying which
2815              responses from the server should be printed.  All  responses  go
2816              to  standard  error.  If any of the numbers 1 to 5 appear in the
2817              string, raw responses from the server with reply codes beginning
2818              with  that  digit  will be printed to standard error.  The first
2819              digit of the three digit reply code is defined by RFC959 to cor‐
2820              respond to:
2821
2822              1.     A positive preliminary reply.
2823
2824              2.     A positive completion reply.
2825
2826              3.     A positive intermediate reply.
2827
2828              4.     A transient negative completion reply.
2829
2830              5.     A permanent negative completion reply.
2831
2832              It should be noted that, for unknown reasons, the reply `Service
2833              not available', which forces termination  of  a  connection,  is
2834              classified  as  421,  i.e.  `transient negative', an interesting
2835              interpretation of the word `transient'.
2836
2837              The code 0 is special:  it indicates that all but the last  line
2838              of  multiline  replies  read  from the server will be printed to
2839              standard error in a processed format.   By  convention,  servers
2840              use this mechanism for sending information for the user to read.
2841              The appropriate reply code, if it  matches  the  same  response,
2842              takes priority.
2843
2844              If  ZFTP_VERBOSE  is not set when zftp is loaded, it will be set
2845              to the default value 450, i.e., messages destined for  the  user
2846              and  all  errors  will  be  printed.  A null string is valid and
2847              specifies that no messages should be printed.
2848
2849   Functions
2850       zftp_chpwd
2851              If this function is set by the user, it is called every time the
2852              directory changes on the server, including when a user is logged
2853              in, or when a connection is closed.  In the last case, $ZFTP_PWD
2854              will be unset; otherwise it will reflect the new directory.
2855
2856       zftp_progress
2857              If  this function is set by the user, it will be called during a
2858              get, put or append operation each time sufficient data has  been
2859              received from the host.  During a get, the data is sent to stan‐
2860              dard output, so it is vital that this function should  write  to
2861              standard error or directly to the terminal, not to standard out‐
2862              put.
2863
2864              When it is called with a transfer  in  progress,  the  following
2865              additional shell parameters are set:
2866
2867              ZFTP_FILE
2868                     The name of the remote file being transferred from or to.
2869
2870              ZFTP_TRANSFER
2871                     A G for a get operation and a P for a put operation.
2872
2873              ZFTP_SIZE
2874                     The  total  size  of the complete file being transferred:
2875                     the same as the first value provided by  the  remote  and
2876                     local  subcommands  for a particular file.  If the server
2877                     cannot  supply  this  value  for  a  remote  file   being
2878                     retrieved,  it  will not be set.  If input is from a pipe
2879                     the value may be incorrect and  correspond  simply  to  a
2880                     full pipe buffer.
2881
2882              ZFTP_COUNT
2883                     The  amount  of data so far transferred; a number between
2884                     zero and $ZFTP_SIZE, if that  is  set.   This  number  is
2885                     always available.
2886
2887              The  function  is initially called with ZFTP_TRANSFER set appro‐
2888              priately and ZFTP_COUNT set to zero.  After the transfer is fin‐
2889              ished,   the   function  will  be  called  one  more  time  with
2890              ZFTP_TRANSFER set to GF or PF, in case it wishes to tidy up.  It
2891              is   otherwise  never  called  twice  with  the  same  value  of
2892              ZFTP_COUNT.
2893
2894              Sometimes the progress meter may cause disruption.  It is up  to
2895              the user to decide whether the function should be defined and to
2896              use unfunction when necessary.
2897
2898   Problems
2899       A connection may not be opened in the left hand side of a pipe as  this
2900       occurs  in  a  subshell  and the file information is not updated in the
2901       main shell.  In the case of type or mode changes or closing the connec‐
2902       tion  in  a subshell, the information is returned but variables are not
2903       updated until the next call to zftp.  Other status changes in subshells
2904       will not be reflected by changes to the variables (but should be other‐
2905       wise harmless).
2906
2907       Deleting sessions while a zftp command is active in the background  can
2908       have  unexpected  effects,  even  if  it does not use the session being
2909       deleted.  This is because all shell subprocesses share  information  on
2910       the state of all connections, and deleting a session changes the order‐
2911       ing of that information.
2912
2913       On some operating systems, the control connection is not valid after  a
2914       fork(),  so  that  operations  in subshells, on the left hand side of a
2915       pipeline, or in the background are not possible,  as  they  should  be.
2916       This is presumably a bug in the operating system.
2917

THE ZSH/ZLE MODULE

2919       The zsh/zle module contains the Zsh Line Editor.  See zshzle(1).
2920

THE ZSH/ZLEPARAMETER MODULE

2922       The  zsh/zleparameter module defines two special parameters that can be
2923       used to access internal information of the Zsh Line  Editor  (see  zsh‐
2924       zle(1)).
2925
2926       keymaps
2927              This array contains the names of the keymaps currently defined.
2928
2929       widgets
2930              This  associative  array contains one entry per widget. The name
2931              of the widget is the key and the value gives  information  about
2932              the widget. It is either
2933                the string `builtin' for builtin widgets,
2934                a string of the form `user:name' for user-defined widgets,
2935                  where  name  is  the name of the shell function implementing
2936              the widget,
2937                a string of the form `completion:type:name'
2938                  for completion widgets,
2939                or a null value if the widget is not yet  fully  defined.   In
2940              the penultimate case, type is the name of the builtin widget the
2941              completion widget imitates in its behavior and name is the  name
2942              of the shell function implementing the completion widget.
2943

THE ZSH/ZPROF MODULE

2945       When  loaded, the zsh/zprof causes shell functions to be profiled.  The
2946       profiling results can be obtained with the zprof builtin  command  made
2947       available  by this module.  There is no way to turn profiling off other
2948       than unloading the module.
2949
2950       zprof [ -c ]
2951              Without the -c option, zprof lists profiling results to standard
2952              output.   The  format  is  comparable  to  that of commands like
2953              gprof.
2954
2955              At the top there is a summary listing all  functions  that  were
2956              called  at  least  once.   This  summary is sorted in decreasing
2957              order of the amount of time spent in each.   The  lines  contain
2958              the  number  of  the  function  in order, which is used in other
2959              parts of the list in suffixes of the form `[num]', then the num‐
2960              ber  of calls made to the function.  The next three columns list
2961              the time in milliseconds spent in the function and  its  descen‐
2962              dants,  the  average  time in milliseconds spent in the function
2963              and its descendants per call and the percentage of time spent in
2964              all  shell  functions used in this function and its descendants.
2965              The following three  columns  give  the  same  information,  but
2966              counting  only the time spent in the function itself.  The final
2967              column shows the name of the function.
2968
2969              After the summary, detailed  information  about  every  function
2970              that  was  invoked  is listed, sorted in decreasing order of the
2971              amount of time spent in each function and its descendants.  Each
2972              of these entries consists of descriptions for the functions that
2973              called the function described,  the  function  itself,  and  the
2974              functions  that  were  called  from it.  The description for the
2975              function itself has the same format as in the summary (and shows
2976              the same information).  The other lines don't show the number of
2977              the function at the beginning  and  have  their  function  named
2978              indented  to  make it easier to distinguish the line showing the
2979              function described in the section from the surrounding lines.
2980
2981              The information shown in this case is almost the same as in  the
2982              summary,  but only refers to the call hierarchy being displayed.
2983              For example, for a calling function the column showing the total
2984              running  time lists the time spent in the described function and
2985              its descendants only for the times when it was called from  that
2986              particular  calling  function.  Likewise, for a called function,
2987              this columns lists the total time spent in the  called  function
2988              and  its  descendants only for the times when it was called from
2989              the function described.
2990
2991              Also in this case, the column showing the number of calls  to  a
2992              function also shows a slash and then the total number of invoca‐
2993              tions made to the called function.
2994
2995              As long as the zsh/zprof module is  loaded,  profiling  will  be
2996              done  and multiple invocations of the zprof builtin command will
2997              show the times and numbers of calls since the module was loaded.
2998              With  the  -c  option,  the zprof builtin command will reset its
2999              internal counters and will not show the listing.
3000

THE ZSH/ZPTY MODULE

3002       The zsh/zpty module offers one builtin:
3003
3004       zpty [ -e ] [ -b ] name [ arg ... ]
3005              The  arguments  following  name  are  concatenated  with  spaces
3006              between,  then  executed  as a command, as if passed to the eval
3007              builtin.  The command runs under a newly assigned  pseudo-termi‐
3008              nal; this is useful for running commands non-interactively which
3009              expect an interactive environment.  The name is not part of  the
3010              command,  but is used to refer to this command in later calls to
3011              zpty.
3012
3013              With the -e option, the pseudo-terminal is set up so that  input
3014              characters are echoed.
3015
3016              With the -b option, input to and output from the pseudo-terminal
3017              are made non-blocking.
3018
3019              The shell parameter REPLY is set to the file descriptor assigned
3020              to the master side of the pseudo-terminal.  This allows the ter‐
3021              minal to be monitored with ZLE  descriptor  handlers  (see  zsh‐
3022              zle(1))  or  manipulated  with  sysread  and  syswrite  (see THE
3023              ZSH/SYSTEM MODULE in zshmodules(1)).  Warning:  Use  of  sysread
3024              and  syswrite is not recommended, use zpty -r and zpty -w unless
3025              you know exactly what you are doing.
3026
3027       zpty -d [ name ... ]
3028              The second form, with the -d option, is used to delete  commands
3029              previously  started,  by supplying a list of their names.  If no
3030              name is given, all commands are  deleted.   Deleting  a  command
3031              causes the HUP signal to be sent to the corresponding process.
3032
3033       zpty -w [ -n ] name [ string ... ]
3034              The  -w option can be used to send the to command name the given
3035              strings as input (separated by spaces).  If the -n option is not
3036              given, a newline is added at the end.
3037
3038              If  no  string  is provided, the standard input is copied to the
3039              pseudo-terminal; this may stop before copying the full input  if
3040              the pseudo-terminal is non-blocking.
3041
3042              Note  that the command under the pseudo-terminal sees this input
3043              as if it were typed, so beware when sending special  tty  driver
3044              characters such as word-erase, line-kill, and end-of-file.
3045
3046       zpty -r [ -mt ] name [ param [ pattern ] ]
3047              The  -r  option  can  be  used to read the output of the command
3048              name.  With only a name argument, the output read is  copied  to
3049              the  standard  output.  Unless the pseudo-terminal is non-block‐
3050              ing, copying continues until the command under the pseudo-termi‐
3051              nal  exits; when non-blocking, only as much output as is immedi‐
3052              ately available is copied.  The return status  is  zero  if  any
3053              output is copied.
3054
3055              When  also  given a param argument, at most one line is read and
3056              stored in the parameter named param.  Less than a full line  may
3057              be read if the pseudo-terminal is non-blocking.  The return sta‐
3058              tus is zero if at least one character is stored in param.
3059
3060              If a pattern is given as well, output is read  until  the  whole
3061              string  read matches the pattern, even in the non-blocking case.
3062              The return status is zero if the string read  matches  the  pat‐
3063              tern,  or  if  the command has exited but at least one character
3064              could still be read.  If the option -m is  present,  the  return
3065              status is zero only if the pattern matches.  As of this writing,
3066              a maximum of one megabyte of output can be consumed this way; if
3067              a full megabyte is read without matching the pattern, the return
3068              status is non-zero.
3069
3070              In all cases, the return status is non-zero if nothing could  be
3071              read, and is 2 if this is because the command has finished.
3072
3073              If  the  -r  option  is  combined with the -t option, zpty tests
3074              whether output is available before trying to read.  If no output
3075              is  available, zpty immediately returns the status 1.  When used
3076              with a pattern, the behaviour on a failed  poll  is  similar  to
3077              when  the  command  has  exited:  the return value is zero if at
3078              least one character could still be  read  even  if  the  pattern
3079              failed to match.
3080
3081       zpty -t name
3082              The  -t option without the -r option can be used to test whether
3083              the command name is still running.  It returns a zero status  if
3084              the command is running and a non-zero value otherwise.
3085
3086       zpty [ -L ]
3087              The  last  form, without any arguments, is used to list the com‐
3088              mands currently defined.  If the -L option  is  given,  this  is
3089              done in the form of calls to the zpty builtin.
3090

THE ZSH/ZSELECT MODULE

3092       The zsh/zselect module makes available one builtin command:
3093
3094       zselect [ -rwe ] [ -t timeout ] [ -a array ] [ -A assoc ] [ fd ... ]
3095              The  zselect builtin is a front-end to the `select' system call,
3096              which blocks until a file descriptor is  ready  for  reading  or
3097              writing,  or  has  an error condition, with an optional timeout.
3098              If this is not available on your system, the command  prints  an
3099              error  message and returns status 2 (normal errors return status
3100              1).  For more information, see your  systems  documentation  for
3101              select(3).   Note  there is no connection with the shell builtin
3102              of the same name.
3103
3104              Arguments  and  options  may  be  intermingled  in  any   order.
3105              Non-option arguments are file descriptors, which must be decimal
3106              integers.  By default, file descriptors are  to  be  tested  for
3107              reading,  i.e.  zselect will return when data is available to be
3108              read from the file descriptor, or more precisely,  when  a  read
3109              operation  from the file descriptor will not block.  After a -r,
3110              -w and -e, the given file descriptors are to be tested for read‐
3111              ing,  writing,  or error conditions.  These options and an arbi‐
3112              trary list of file descriptors may be given in any order.
3113
3114              (The presence of an `error condition' is not well defined in the
3115              documentation  for  many  implementations  of  the select system
3116              call.  According to recent versions of the POSIX  specification,
3117              it  is really an exception condition, of which the only standard
3118              example is out-of-band data received on a socket.  So zsh  users
3119              are unlikely to find the -e option useful.)
3120
3121              The  option  `-t timeout' specifies a timeout in hundredths of a
3122              second.  This may be zero, in which case  the  file  descriptors
3123              will  simply  be polled and zselect will return immediately.  It
3124              is possible to call zselect  with  no  file  descriptors  and  a
3125              non-zero  timeout  for  use  as  a finer-grained replacement for
3126              `sleep'; note, however, the return status  is  always  1  for  a
3127              timeout.
3128
3129              The  option  `-a  array'  indicates  that array should be set to
3130              indicate the file descriptor(s) which are ready.  If the  option
3131              is  not  given,  the  array reply will be used for this purpose.
3132              The array will contain a string similar  to  the  arguments  for
3133              zselect.  For example,
3134
3135                     zselect -t 0 -r 0 -w 1
3136
3137              might return immediately with status 0 and $reply containing `-r
3138              0 -w 1' to show that both file descriptors  are  ready  for  the
3139              requested operations.
3140
3141              The option `-A assoc' indicates that the associative array assoc
3142              should be set to  indicate  the  file  descriptor(s)  which  are
3143              ready.   This  option overrides the option -a, nor will reply be
3144              modified.  The keys of assoc are the file descriptors,  and  the
3145              corresponding values are any of the characters `rwe' to indicate
3146              the condition.
3147
3148              The command returns status 0 if some file descriptors are  ready
3149              for  reading.  If the operation timed out, or a timeout of 0 was
3150              given and no file descriptors were ready, or there was an error,
3151              it  returns status 1 and the array will not be set (nor modified
3152              in any way).  If there was an error in the select operation  the
3153              appropriate error message is printed.
3154

THE ZSH/ZUTIL MODULE

3156       The zsh/zutil module only adds some builtins:
3157
3158       zstyle [ -L [ pattern [ style ] ] ]
3159       zstyle [ -e | - | -- ] pattern style string ...
3160       zstyle -d [ pattern [ style ... ] ]
3161       zstyle -g name [ pattern [ style ] ]
3162       zstyle -{a|b|s} context style name [ sep ]
3163       zstyle -{T|t} context style [ string ... ]
3164       zstyle -m context style pattern
3165              This  builtin  command  is  used  to  define  and lookup styles.
3166              Styles are pairs of names and values, where the  values  consist
3167              of  any  number  of strings.  They are stored together with pat‐
3168              terns and lookup is done by giving a string,  called  the  `con‐
3169              text', which is compared to the patterns.  The definition stored
3170              for the first matching pattern will be returned.
3171
3172              For ordering of comparisons, patterns  are  searched  from  most
3173              specific  to  least specific, and patterns that are equally spe‐
3174              cific keep the order in which they were defined.  A  pattern  is
3175              considered  to be more specific than another if it contains more
3176              components (substrings separated by colons) or if  the  patterns
3177              for  the  components are more specific, where simple strings are
3178              considered to be more specific than patterns  and  complex  pat‐
3179              terns are considered to be more specific than the pattern `*'.
3180
3181              The  first  form  (without  arguments)  lists  the  definitions.
3182              Styles are shown in alphabetic order and patterns are  shown  in
3183              the order zstyle will test them.
3184
3185              If  the -L option is given, listing is done in the form of calls
3186              to zstyle.  The optional first argument is a pattern which  will
3187              be  matched  against  the string supplied as the pattern for the
3188              context; note that this means, for example, `zstyle -L ":comple‐
3189              tion:*"'  will  match  any  supplied pattern beginning `:comple‐
3190              tion:', not just ":completion:*":  use ":completion:\*" to match
3191              that.   The optional second argument limits the output to a spe‐
3192              cific style (not a pattern).  -L  is  not  compatible  with  any
3193              other options.
3194
3195              The other forms are the following:
3196
3197              zstyle [ - | -- | -e ] pattern style string ...
3198                     Defines  the given style for the pattern with the strings
3199                     as the value.  If the -e option  is  given,  the  strings
3200                     will  be  concatenated  (separated  by  spaces)  and  the
3201                     resulting string will be evaluated (in the same way as it
3202                     is  done  by  the eval builtin command) when the style is
3203                     looked up.  In this case the parameter  `reply'  must  be
3204                     assigned  to  set  the strings returned after the evalua‐
3205                     tion.  Before evaluating the value, reply is  unset,  and
3206                     if  it  is still unset after the evaluation, the style is
3207                     treated as if it were not set.
3208
3209              zstyle -d [ pattern [ style ... ] ]
3210                     Delete style definitions. Without arguments  all  defini‐
3211                     tions  are  deleted,  with  a pattern all definitions for
3212                     that pattern are deleted and if  any  styles  are  given,
3213                     then only those styles are deleted for the pattern.
3214
3215              zstyle -g name [ pattern [ style ] ]
3216                     Retrieve a style definition. The name is used as the name
3217                     of an array in which the results are stored. Without  any
3218                     further  arguments,  all  patterns  defined are returned.
3219                     With a pattern the styles defined for  that  pattern  are
3220                     returned  and  with both a pattern and a style, the value
3221                     strings of that combination is returned.
3222
3223              The other forms can be used to look up or test patterns.
3224
3225              zstyle -s context style name [ sep ]
3226                     The parameter name is set  to  the  value  of  the  style
3227                     interpreted  as  a string.  If the value contains several
3228                     strings they are concatenated with spaces  (or  with  the
3229                     sep string if that is given) between them.
3230
3231              zstyle -b context style name
3232                     The  value  is  stored  in name as a boolean, i.e. as the
3233                     string `yes' if the value has only one  string  and  that
3234                     string is equal to one of `yes', `true', `on', or `1'. If
3235                     the value is any  other  string  or  has  more  than  one
3236                     string, the parameter is set to `no'.
3237
3238              zstyle -a context style name
3239                     The  value  is  stored  in  name  as an array. If name is
3240                     declared as an associative array,  the first, third, etc.
3241                     strings  are  used  as the keys and the other strings are
3242                     used as the values.
3243
3244              zstyle -t context style [ string ... ]
3245              zstyle -T context style [ string ... ]
3246                     Test the value of  a  style,  i.e.  the  -t  option  only
3247                     returns  a  status  (sets  $?).   Without  any string the
3248                     return status is zero if the  style  is  defined  for  at
3249                     least  one  matching  pattern, has only one string in its
3250                     value, and that is equal to one of `true', `yes', `on' or
3251                     `1'.  If  any strings are given the status is zero if and
3252                     only if at least one of the strings is equal to at  least
3253                     one  of the strings in the value. If the style is defined
3254                     but doesn't match, the return status is 1. If  the  style
3255                     is not defined, the status is 2.
3256
3257                     The  -T option tests the values of the style like -t, but
3258                     it returns status zero (rather than 2) if  the  style  is
3259                     not defined for any matching pattern.
3260
3261              zstyle -m context style pattern
3262                     Match a value. Returns status zero if the pattern matches
3263                     at least one of the strings in the value.
3264
3265       zformat -f param format spec ...
3266       zformat -a array sep spec ...
3267              This builtin provides two different  forms  of  formatting.  The
3268              first form is selected with the -f option. In this case the for‐
3269              mat string will be modified by replacing sequences starting with
3270              a  percent  sign  in  it with strings from the specs.  Each spec
3271              should be of the  form  `char:string'  which  will  cause  every
3272              appearance  of  the sequence `%char' in format to be replaced by
3273              the string.  The `%' sequence may also contain optional  minimum
3274              and  maximum  field width specifications between the `%' and the
3275              `char' in the form `%min.maxc', i.e. the minimum field width  is
3276              given first and if the maximum field width is used, it has to be
3277              preceded by a dot.  Specifying a minimum field width  makes  the
3278              result  be  padded  with  spaces  to  the right if the string is
3279              shorter than the requested width.  Padding to the  left  can  be
3280              achieved by giving a negative minimum field width.  If a maximum
3281              field width is specified, the string  will  be  truncated  after
3282              that  many  characters.   After  all `%' sequences for the given
3283              specs have been processed, the resulting string is stored in the
3284              parameter param.
3285
3286              The  %-escapes  also  understand ternary expressions in the form
3287              used by prompts.  The % is followed by a `(' and then  an  ordi‐
3288              nary  format  specifier character as described above.  There may
3289              be a set of digits either before or after the `('; these specify
3290              a  test  number,  which  defaults to zero.  Negative numbers are
3291              also allowed.  An arbitrary delimiter character follows the for‐
3292              mat  specifier, which is followed by a piece of `true' text, the
3293              delimiter character again, a piece of `false' text, and a  clos‐
3294              ing  parenthesis.   The complete expression (without the digits)
3295              thus looks like `%(X.text1.text2)', except that the `.'  charac‐
3296              ter  is  arbitrary.  The value given for the format specifier in
3297              the char:string  expressions  is  evaluated  as  a  mathematical
3298              expression,  and compared with the test number.  If they are the
3299              same, text1 is output, else text2 is output.  A parenthesis  may
3300              be escaped in text2 as %).  Either of text1 or text2 may contain
3301              nested %-escapes.
3302
3303              For example:
3304
3305                     zformat -f REPLY "The answer is '%3(c.yes.no)'." c:3
3306
3307              outputs "The answer is 'yes'." to REPLY since the value for  the
3308              format specifier c is 3, agreeing with the digit argument to the
3309              ternary expression.
3310
3311              The second form, using the -a option, can be used  for  aligning
3312              strings.   Here,  the  specs  are of the form `left:right' where
3313              `left' and `right' are arbitrary  strings.   These  strings  are
3314              modified  by  replacing the colons by the sep string and padding
3315              the left strings with spaces  to  the  right  so  that  the  sep
3316              strings  in  the result (and hence the right strings after them)
3317              are all aligned if the strings are  printed  below  each  other.
3318              All  strings  without a colon are left unchanged and all strings
3319              with an empty right string have the trailing colon removed.   In
3320              both  cases the lengths of the strings are not used to determine
3321              how the other strings are to be aligned.  The resulting  strings
3322              are stored in the array.
3323
3324       zregexparse
3325              This implements some internals of the _regex_arguments function.
3326
3327       zparseopts [ -D -K -M -E ] [ -a array ] [ -A assoc ] [ - ] spec ...
3328              This  builtin  simplifies  the  parsing of options in positional
3329              parameters, i.e. the set of arguments given by  $*.   Each  spec
3330              describes  one option and must be of the form `opt[=array]'.  If
3331              an option described by opt is found in the positional parameters
3332              it is copied into the array specified with the -a option; if the
3333              optional `=array' is given,  it  is  instead  copied  into  that
3334              array,  which  should be declared as a normal array and never as
3335              an associative array.
3336
3337              Note that it is an error to give any spec  without  an  `=array'
3338              unless one of the -a or -A options is used.
3339
3340              Unless the -E option is given, parsing stops at the first string
3341              that isn't described by one of the specs.  Even with -E, parsing
3342              always stops at a positional parameter equal to `-' or `--'.
3343
3344              The  opt  description  must be one of the following.  Any of the
3345              special characters can appear in the option name provided it  is
3346              preceded by a backslash.
3347
3348              name
3349              name+  The  name  is  the name of the option without the leading
3350                     `-'.  To specify a GNU-style  long  option,  one  of  the
3351                     usual two leading `-' must be included in name; for exam‐
3352                     ple, a `--file'  option  is  represented  by  a  name  of
3353                     `-file'.
3354
3355                     If  a  `+'  appears after name, the option is appended to
3356                     array each time it is found in the positional parameters;
3357                     without the `+' only the last occurrence of the option is
3358                     preserved.
3359
3360                     If one of these forms is used, the option takes no  argu‐
3361                     ment,  so  parsing stops if the next positional parameter
3362                     does not also begin with `-' (unless  the  -E  option  is
3363                     used).
3364
3365              name:
3366              name:-
3367              name:: If one or two colons are given, the option takes an argu‐
3368                     ment; with one colon, the argument is mandatory and  with
3369                     two  colons  it is optional.  The argument is appended to
3370                     the array after the option itself.
3371
3372                     An optional argument is put into the same  array  element
3373                     as the option name (note that this makes empty strings as
3374                     arguments indistinguishable).  A  mandatory  argument  is
3375                     added as a separate element unless the `:-' form is used,
3376                     in which case the argument is put into the same element.
3377
3378                     A `+' as described above may appear between the name  and
3379                     the first colon.
3380
3381              The  options of zparseopts itself cannot be stacked because, for
3382              example, the stack `-DEK' is indistinguishable from a  spec  for
3383              the  GNU-style  long  option `--DEK'.  The options of zparseopts
3384              itself are:
3385
3386              -a array
3387                     As described above, this names the default array in which
3388                     to store the recognised options.
3389
3390              -A assoc
3391                     If  this  is given, the options and their values are also
3392                     put into an associative array with the  option  names  as
3393                     keys and the arguments (if any) as the values.
3394
3395              -D     If  this  option  is given, all options found are removed
3396                     from the positional parameters of the  calling  shell  or
3397                     shell function, up to but not including any not described
3398                     by the  specs.   This  is  similar  to  using  the  shift
3399                     builtin.
3400
3401              -K     With this option, the arrays specified with the -a option
3402                     and with the `=array' forms are kept unchanged when  none
3403                     of  the  specs  for  them  is used.  Otherwise the entire
3404                     array is replaced when any of the specs is  used.   Indi‐
3405                     vidual  elements of associative arrays specified with the
3406                     -A option are preserved by -K.  This allows assignment of
3407                     default values to arrays before calling zparseopts.
3408
3409              -M     This  changes  the  assignment  rules  to implement a map
3410                     among equivalent option names.   If  any  spec  uses  the
3411                     `=array'  form,  the  string  array is interpreted as the
3412                     name of another spec, which is used to  choose  where  to
3413                     store  the values.  If no other spec is found, the values
3414                     are stored as usual.  This changes only the way the  val‐
3415                     ues  are stored, not the way $* is parsed, so results may
3416                     be unpredictable if the `name+' specifier is used  incon‐
3417                     sistently.
3418
3419              -E     This  changes  the parsing rules to not stop at the first
3420                     string that isn't described by one of the specs.  It  can
3421                     be used to test for or (if used together with -D) extract
3422                     options and their arguments, ignoring all  other  options
3423                     and arguments that may be in the positional parameters.
3424
3425              For example,
3426
3427                     set -- -a -bx -c y -cz baz -cend
3428                     zparseopts a=foo b:=bar c+:=bar
3429
3430              will have the effect of
3431
3432                     foo=(-a)
3433                     bar=(-b x -c y -c z)
3434
3435              The arguments from `baz' on will not be used.
3436
3437              As an example for the -E option, consider:
3438
3439                     set -- -a x -b y -c z arg1 arg2
3440                     zparseopts -E -D b:=bar
3441
3442              will have the effect of
3443
3444                     bar=(-b y)
3445                     set -- -a x -c z arg1 arg2
3446
3447              I.e.,  the  option -b and its arguments are taken from the posi‐
3448              tional parameters and put into the array bar.
3449
3450              The -M option can be used like this:
3451
3452                     set -- -a -bx -c y -cz baz -cend
3453                     zparseopts -A bar -M a=foo b+: c:=b
3454
3455              to have the effect of
3456
3457                     foo=(-a)
3458                     bar=(-a '' -b xyz)
3459
3460
3461
3462zsh 5.5.1                       April 16, 2018                   ZSHMODULES(1)
Impressum