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, log2,
1322       logb, sin, sinh, sqrt, tan,  tanh,  y0,  y1.   The  atan  function  can
1323       optionally  take a second argument, in which case it behaves like the C
1324       function atan2.  The ilogb function takes a single floating point argu‐
1325       ment, but 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 format string supports
2038                     all of the zsh extensions described in the section EXPAN‐
2039                     SION OF PROMPT SEQUENCES in zshmisc(1).  The -s option is
2040                     implied.
2041
2042              -g     Show the time elements in the  GMT  time  zone.   The  -s
2043                     option is implied.
2044
2045              -l     List  the  names of the type elements (to standard output
2046                     or an array as appropriate) and return immediately; argu‐
2047                     ments, and options other than -A, are ignored.
2048
2049              -L     Perform an lstat (see lstat(2)) rather than a stat system
2050                     call.  In this case, if the file is a  link,  information
2051                     about  the  link  itself  rather  than the target file is
2052                     returned.  This option is required to make the link  ele‐
2053                     ment  useful.   It's  important  to note that this is the
2054                     exact opposite from ls(1), etc.
2055
2056              -n     Always show the names of files.  Usually these  are  only
2057                     shown when output is to standard output and there is more
2058                     than one file in the list.
2059
2060              -N     Never show the names of files.
2061
2062              -o     If a raw file mode is printed, show it in octal, which is
2063                     more  useful  for  human  consumption than the default of
2064                     decimal.  A leading zero will be printed  in  this  case.
2065                     Note that this does not affect whether a raw or formatted
2066                     file mode is shown, which is controlled by the -r and  -s
2067                     options, nor whether a mode is shown at all.
2068
2069              -r     Print raw data (the default format) alongside string data
2070                     (the -s format); the string data appears  in  parentheses
2071                     after the raw data.
2072
2073              -s     Print  mode,  uid,  gid  and  the  three time elements as
2074                     strings instead of numbers.  In each case the  format  is
2075                     like that of ls -l.
2076
2077              -t     Always  show  the  type  names for the elements of struct
2078                     stat.  Usually these are only shown  when  output  is  to
2079                     standard  output  and  no  individual  element  has  been
2080                     selected.
2081
2082              -T     Never show the type names of the struct stat elements.
2083

THE ZSH/SYSTEM MODULE

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

THE ZSH/NET/TCP MODULE

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

THE ZSH/TERMCAP MODULE

2452       The zsh/termcap module makes available one builtin command:
2453
2454       echotc cap [ arg ... ]
2455              Output the termcap value corresponding to  the  capability  cap,
2456              with optional arguments.
2457
2458       The zsh/termcap module makes available one parameter:
2459
2460       termcap
2461              An associative array that maps termcap capability codes to their
2462              values.
2463

THE ZSH/TERMINFO MODULE

2465       The zsh/terminfo module makes available one builtin command:
2466
2467       echoti cap [ arg ]
2468              Output the terminfo value corresponding to the  capability  cap,
2469              instantiated with arg if applicable.
2470
2471       The zsh/terminfo module makes available one parameter:
2472
2473       terminfo
2474              An  associative  array  that  maps  terminfo capability names to
2475              their values.
2476

THE ZSH/ZFTP MODULE

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

THE ZSH/ZLE MODULE

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

THE ZSH/ZLEPARAMETER MODULE

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

THE ZSH/ZPROF MODULE

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

THE ZSH/ZPTY MODULE

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

THE ZSH/ZSELECT MODULE

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

THE ZSH/ZUTIL MODULE

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