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/nearcolor
70              Map colours to the nearest colour in the available palette.
71
72       zsh/newuser
73              Arrange for files for new users to be installed.
74
75       zsh/parameter
76              Access to internal hash tables via special associative arrays.
77
78       zsh/pcre
79              Interface to the PCRE library.
80
81       zsh/param/private
82              Builtins for managing private-scoped parameters in function con‐
83              text.
84
85       zsh/regex
86              Interface to the POSIX regex library.
87
88       zsh/sched
89              A builtin that provides a timed execution  facility  within  the
90              shell.
91
92       zsh/net/socket
93              Manipulation of Unix domain sockets
94
95       zsh/stat
96              A builtin command interface to the stat system call.
97
98       zsh/system
99              A builtin interface to various low-level system features.
100
101       zsh/net/tcp
102              Manipulation of TCP sockets
103
104       zsh/termcap
105              Interface to the termcap database.
106
107       zsh/terminfo
108              Interface to the terminfo database.
109
110       zsh/zftp
111              A builtin FTP client.
112
113       zsh/zle
114              The Zsh Line Editor, including the bindkey and vared builtins.
115
116       zsh/zleparameter
117              Access to internals of the Zsh Line Editor via parameters.
118
119       zsh/zprof
120              A module allowing profiling for shell functions.
121
122       zsh/zpty
123              A builtin for starting a command in a pseudo-terminal.
124
125       zsh/zselect
126              Block and return when file descriptors are ready.
127
128       zsh/zutil
129              Some utility builtins, e.g. the one for supporting configuration
130              via styles.
131

THE ZSH/ATTR MODULE

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

THE ZSH/CAP MODULE

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

THE ZSH/CLONE MODULE

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

THE ZSH/COMPCTL MODULE

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

THE ZSH/COMPLETE MODULE

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

THE ZSH/COMPLIST MODULE

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

THE ZSH/COMPUTIL MODULE

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

THE ZSH/CURSES MODULE

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

THE ZSH/DATETIME MODULE

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

THE ZSH/DB/GDBM MODULE

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

THE ZSH/DELTOCHAR MODULE

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

THE ZSH/EXAMPLE MODULE

1081       The zsh/example module makes available one builtin command:
1082
1083       example [ -flags ] [ args ... ]
1084              Displays the flags and arguments it is invoked with.
1085
1086       The purpose of the module is to serve as an example of how to  write  a
1087       module.
1088

THE ZSH/FILES MODULE

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

THE ZSH/LANGINFO MODULE

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

THE ZSH/MAPFILE MODULE

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

THE ZSH/MATHFUNC MODULE

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

THE ZSH/NEARCOLOR MODULE

1395       The  zsh/nearcolor  module  replaces  colours specified as hex triplets
1396       with the nearest colour in the 88  or  256  colour  palettes  that  are
1397       widely  used  by  terminal  emulators.   By default, 24-bit true colour
1398       escape codes  are  generated  when  colours  are  specified  using  hex
1399       triplets.   These  are  not supported by all terminals.  The purpose of
1400       this module is to make it easier to define colour preferences in a form
1401       that can work across a range of terminal emulators.
1402
1403       Aside  from  the  default colour, the ANSI standard for terminal escape
1404       codes provides for eight colours. The bright attribute brings  this  to
1405       sixteen. These basic colours are commonly used in terminal applications
1406       due to being widely supported. Expanded 88 and 256 colour palettes  are
1407       also  common and, while the first sixteen colours vary somewhat between
1408       terminals and configurations, these add a generally consistent and pre‐
1409       dictable set of colours.
1410
1411       In  order  to use the zsh/nearcolor module, it only needs to be loaded.
1412       Thereafter, whenever a colour is specified using a hex triplet, it will
1413       be  compared against each of the available colours and the closest will
1414       be selected. The first  sixteen  colours  are  never  matched  in  this
1415       process due to being unpredictable.
1416
1417       It  isn't  possible  to  reliably detect support for true colour in the
1418       terminal emulator. It is therefore recommended to be selective in load‐
1419       ing  the  zsh/nearcolor  module.  For example, the following checks the
1420       COLORTERM environment variable:
1421
1422              [[ $COLORTERM = *(24bit|truecolor)* ]] || zmodload zsh/nearcolor
1423
1424       Note that some terminals accept the true color  escape  codes  but  map
1425       them  internally  to  a more limited palette in a similar manner to the
1426       zsh/nearcolor module.
1427

THE ZSH/NEWUSER MODULE

1429       The zsh/newuser module is loaded at boot if it is  available,  the  RCS
1430       option is set, and the PRIVILEGED option is not set (all three are true
1431       by default).  This takes place immediately after commands in the global
1432       zshenv  file  (typically  /etc/zshenv), if any, have been executed.  If
1433       the module is not available it is silently ignored by  the  shell;  the
1434       module  may safely be removed from $MODULE_PATH by the administrator if
1435       it is not required.
1436
1437       On loading, the module tests if any  of  the  start-up  files  .zshenv,
1438       .zprofile,  .zshrc or .zlogin exist in the directory given by the envi‐
1439       ronment variable ZDOTDIR, or the user's home directory if that  is  not
1440       set.   The test is not performed and the module halts processing if the
1441       shell was in an emulation mode (i.e. had been  invoked  as  some  other
1442       shell than zsh).
1443
1444       If none of the start-up files were found, the module then looks for the
1445       file newuser first in a sitewide directory, usually the  parent  direc‐
1446       tory of the site-functions directory, and if that is not found the mod‐
1447       ule searches in a version-specific directory, usually the parent of the
1448       functions  directory  containing  version-specific  functions.   (These
1449       directories  can  be  configured  when   zsh   is   built   using   the
1450       --enable-site-scriptdir=dir and --enable-scriptdir=dir flags to config‐
1451       ure,  respectively;  the  defaults  are   prefix/share/zsh   and   pre‐
1452       fix/share/zsh/$ZSH_VERSION where the default prefix is /usr/local.)
1453
1454       If  the file newuser is found, it is then sourced in the same manner as
1455       a start-up file.  The file is  expected  to  contain  code  to  install
1456       start-up  files for the user, however any valid shell code will be exe‐
1457       cuted.
1458
1459       The zsh/newuser module is then unconditionally unloaded.
1460
1461       Note that it is possible to achieve exactly  the  same  effect  as  the
1462       zsh/newuser  module  by  adding code to /etc/zshenv.  The module exists
1463       simply to allow the shell to make arrangements for  new  users  without
1464       the need for intervention by package maintainers and system administra‐
1465       tors.
1466
1467       The  script  supplied  with  the  module  invokes  the  shell  function
1468       zsh-newuser-install.   This may be invoked directly by the user even if
1469       the zsh/newuser module is disabled.  Note, however, that if the  module
1470       is  not installed the function will not be installed either.  The func‐
1471       tion is documented in the section User Configuration Functions in  zsh‐
1472       contrib(1).
1473

THE ZSH/PARAMETER MODULE

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

THE ZSH/PCRE MODULE

1701       The zsh/pcre module makes some commands available as builtins:
1702
1703       pcre_compile [ -aimxs ] PCRE
1704              Compiles a perl-compatible regular expression.
1705
1706              Option -a will force the pattern to be anchored.  Option -i will
1707              compile a case-insensitive pattern.  Option -m  will  compile  a
1708              multi-line  pattern; that is, ^ and $ will match newlines within
1709              the pattern.   Option  -x  will  compile  an  extended  pattern,
1710              wherein  whitespace and # comments are ignored.  Option -s makes
1711              the dot metacharacter match all characters, including those that
1712              indicate newline.
1713
1714       pcre_study
1715              Studies  the previously-compiled PCRE which may result in faster
1716              matching.
1717
1718       pcre_match [ -v var ] [ -a arr ] [ -n offset ] [ -b ] string
1719              Returns successfully if string matches  the  previously-compiled
1720              PCRE.
1721
1722              Upon  successful  match,  if  the expression captures substrings
1723              within parentheses, pcre_match will set the array match to those
1724              substrings, unless the -a option is given, in which case it will
1725              set the array arr.  Similarly, the variable MATCH will be set to
1726              the  entire  matched portion of the string, unless the -v option
1727              is given, in which case the variable var will be set.  No  vari‐
1728              ables  are altered if there is no successful match.  A -n option
1729              starts searching for a match from the byte  offset  position  in
1730              string.   If  the -b option is given, the variable ZPCRE_OP will
1731              be set to an offset pair string, representing  the  byte  offset
1732              positions  of the entire matched portion within the string.  For
1733              example, a ZPCRE_OP set to "32 45" indicates  that  the  matched
1734              portion  began  on  byte  offset 32 and ended on byte offset 44.
1735              Here, byte offset position 45 is the position directly after the
1736              matched portion.  Keep in mind that the byte position isn't nec‐
1737              essarily the same as the character position when  UTF-8  charac‐
1738              ters  are involved.  Consequently, the byte offset positions are
1739              only to be relied on in the context of using them for subsequent
1740              searches  on  string, using an offset position as an argument to
1741              the -n option.  This is mostly used to implement the  "find  all
1742              non-overlapping matches" functionality.
1743
1744              A simple example of "find all non-overlapping matches":
1745
1746                     string="The following zip codes: 78884 90210 99513"
1747                     pcre_compile -m "\d{5}"
1748                     accum=()
1749                     pcre_match -b -- $string
1750                     while [[ $? -eq 0 ]] do
1751                         b=($=ZPCRE_OP)
1752                         accum+=$MATCH
1753                         pcre_match -b -n $b[2] -- $string
1754                     done
1755                     print -l $accum
1756
1757       The zsh/pcre module makes available the following test condition:
1758
1759       expr -pcre-match pcre
1760              Matches a string against a perl-compatible regular expression.
1761
1762              For example,
1763
1764                     [[ "$text" -pcre-match ^d+$ ]] &&
1765                     print text variable contains only "d's".
1766
1767              If the REMATCH_PCRE option is set, the =~ operator is equivalent
1768              to -pcre-match, and the NO_CASE_MATCH option may be used.   Note
1769              that  NO_CASE_MATCH  never  applies  to  the pcre_match builtin,
1770              instead use the -i switch of pcre_compile.
1771

THE ZSH/PARAM/PRIVATE MODULE

1773       The zsh/param/private module is used to create parameters  whose  scope
1774       is  limited  to  the  current function body, and not to other functions
1775       called by the current function.
1776
1777       This module provides a single autoloaded builtin:
1778
1779       private [ {+|-}AHUahlprtux ] [ {+|-}EFLRZi [ n ] ] [ name[=value] ... ]
1780              The private builtin accepts all the same options  and  arguments
1781              as  local  (zshbuiltins(1))  except  for  the `-T' option.  Tied
1782              parameters may not be made private.
1783
1784              If used at the top level (outside  a  function  scope),  private
1785              creates  a  normal  parameter  in  the same manner as declare or
1786              typeset.  A warning about this is printed if  WARN_CREATE_GLOBAL
1787              is  set  (zshoptions(1)).  Used inside a function scope, private
1788              creates a local parameter similar to one  declared  with  local,
1789              except having special properties noted below.
1790
1791              Special  parameters  which  expose  or manipulate internal shell
1792              state, such as ARGC,  argv,  COLUMNS,  LINES,  UID,  EUID,  IFS,
1793              PROMPT, RANDOM, SECONDS, etc., cannot be made private unless the
1794              `-h' option is used to hide the special meaning of  the  parame‐
1795              ter.  This may change in the future.
1796
1797       As  with  other  typeset  equivalents,  private is both a builtin and a
1798       reserved word, so arrays may be assigned with parenthesized  word  list
1799       name=(value...)  syntax.   However,  the reserved word `private' is not
1800       available until zsh/param/private is loaded, so care must be taken with
1801       order  of execution and parsing for function definitions which use pri‐
1802       vate.  To compensate for this, the module also adds the option `-P'  to
1803       the `local' builtin to declare private parameters.
1804
1805       For  example,  this construction fails if zsh/param/private has not yet
1806       been loaded when `bad_declaration' is defined:
1807              bad_declaration() {
1808                zmodload zsh/param/private
1809                private array=( one two three )
1810              }
1811
1812       This construction works because local is already  a  keyword,  and  the
1813       module is loaded before the statement is executed:
1814              good_declaration() {
1815                zmodload zsh/param/private
1816                local -P array=( one two three )
1817              }
1818
1819       The following is usable in scripts but may have trouble with autoload:
1820              zmodload zsh/param/private
1821              iffy_declaration() {
1822                private array=( one two three )
1823              }
1824
1825       The  private builtin may always be used with scalar assignments and for
1826       declarations without assignments.
1827
1828       Parameters declared with private have the following properties:
1829
1830       ·      Within the function body where it  is  declared,  the  parameter
1831              behaves  as  a  local, except as noted above for tied or special
1832              parameters.
1833
1834       ·      The type of a parameter declared private cannot  be  changed  in
1835              the scope where it was declared, even if the parameter is unset.
1836              Thus an array cannot be assigned to a private scalar, etc.
1837
1838       ·      Within any other function called by the declaring function,  the
1839              private  parameter  does  NOT  hide other parameters of the same
1840              name, so for example a global parameter of the same name is vis‐
1841              ible  and  may  be  assigned  or  unset.  This includes calls to
1842              anonymous functions,  although  that  may  also  change  in  the
1843              future.
1844
1845       ·      An  exported  private remains in the environment of inner scopes
1846              but appears unset for the current shell in those scopes.  Gener‐
1847              ally, exporting private parameters should be avoided.
1848
1849       Note  that  this differs from the static scope defined by compiled lan‐
1850       guages derived from C, in that the a new call to the same function cre‐
1851       ates a new scope, i.e., the parameter is still associated with the call
1852       stack rather than with the function definition.  It  differs  from  ksh
1853       `typeset  -S'  because  the  syntax  used to define the function has no
1854       bearing on whether the parameter scope is respected.
1855

THE ZSH/REGEX MODULE

1857       The zsh/regex module makes available the following test condition:
1858
1859       expr -regex-match regex
1860              Matches a string against a POSIX  extended  regular  expression.
1861              On successful match, matched portion of the string will normally
1862              be placed in the MATCH variable.  If  there  are  any  capturing
1863              parentheses within the regex, then the match array variable will
1864              contain those.  If the match is not successful, then  the  vari‐
1865              ables will not be altered.
1866
1867              For example,
1868
1869                     [[ alphabetical -regex-match ^a([^a]+)a([^a]+)a ]] &&
1870                     print -l $MATCH X $match
1871
1872              If the option REMATCH_PCRE is not set, then the =~ operator will
1873              automatically load this module as needed  and  will  invoke  the
1874              -regex-match operator.
1875
1876              If  BASH_REMATCH is set, then the array BASH_REMATCH will be set
1877              instead of MATCH and match.
1878

THE ZSH/SCHED MODULE

1880       The zsh/sched module makes available one builtin command and one param‐
1881       eter.
1882
1883       sched [-o] [+]hh:mm[:ss] command ...
1884       sched [-o] [+]seconds command ...
1885       sched [ -item ]
1886              Make an entry in the scheduled list of commands to execute.  The
1887              time may be specified in either absolute or relative  time,  and
1888              either as hours, minutes and (optionally) seconds separated by a
1889              colon, or seconds alone.  An absolute number  of  seconds  indi‐
1890              cates  the time since the epoch (1970/01/01 00:00); this is use‐
1891              ful in combination with the features in the zsh/datetime module,
1892              see the zsh/datetime module entry in zshmodules(1).
1893
1894              With  no  arguments,  prints the list of scheduled commands.  If
1895              the scheduled command has the -o flag set, this is shown at  the
1896              start of the command.
1897
1898              With the argument `-item', removes the given item from the list.
1899              The numbering of the list is continuous and entries are in  time
1900              order,  so  the  numbering  can change when entries are added or
1901              deleted.
1902
1903              Commands are executed either immediately  before  a  prompt,  or
1904              while the shell's line editor is waiting for input.  In the lat‐
1905              ter case it is useful to be able to produce output that does not
1906              interfere  with  the line being edited.  Providing the option -o
1907              causes the shell to clear the command line before the event  and
1908              redraw  it  afterwards.   This should be used with any scheduled
1909              event that produces visible output to the terminal;  it  is  not
1910              needed,  for example, with output that updates a terminal emula‐
1911              tor's title bar.
1912
1913              To effect changes to the editor buffer when an  event  executes,
1914              use the `zle' command with no arguments to test whether the edi‐
1915              tor is active, and if it is, then use `zle widget' to access the
1916              editor via the named widget.
1917
1918              The  sched  builtin  is  not  made available by default when the
1919              shell starts in a mode emulating another shell.  It can be  made
1920              available with the command `zmodload -F zsh/sched b:sched'.
1921
1922       zsh_scheduled_events
1923              A  readonly  array  corresponding to the events scheduled by the
1924              sched builtin.  The indices of the array correspond to the  num‐
1925              bers  shown  when  sched is run with no arguments (provided that
1926              the KSH_ARRAYS option is not set).  The value of the array  con‐
1927              sists  of the scheduled time in seconds since the epoch (see the
1928              section `The zsh/datetime Module' for facilities for using  this
1929              number), followed by a colon, followed by any options (which may
1930              be empty but will be preceded by a `-' otherwise), followed by a
1931              colon, followed by the command to be executed.
1932
1933              The  sched  builtin  should be used for manipulating the events.
1934              Note that this will have an immediate effect on the contents  of
1935              the array, so that indices may become invalid.
1936

THE ZSH/NET/SOCKET MODULE

1938       The zsh/net/socket module makes available one builtin command:
1939
1940       zsocket [ -altv ] [ -d fd ] [ args ]
1941              zsocket  is  implemented as a builtin to allow full use of shell
1942              command line editing, file I/O, and job control mechanisms.
1943
1944   Outbound Connections
1945       zsocket [ -v ] [ -d fd ] filename
1946              Open a new Unix domain connection to filename.  The shell param‐
1947              eter  REPLY  will  be set to the file descriptor associated with
1948              that connection.  Currently, only stream  connections  are  sup‐
1949              ported.
1950
1951              If  -d  is  specified,  its argument will be taken as the target
1952              file descriptor for the connection.
1953
1954              In order to elicit more verbose output, use -v.
1955
1956              File descriptors can be closed with normal shell syntax when  no
1957              longer needed, for example:
1958
1959                     exec {REPLY}>&-
1960
1961   Inbound Connections
1962       zsocket -l [ -v ] [ -d fd ] filename
1963              zsocket  -l will open a socket listening on filename.  The shell
1964              parameter REPLY will be set to the  file  descriptor  associated
1965              with that listener.
1966
1967              If  -d  is  specified,  its argument will be taken as the target
1968              file descriptor for the connection.
1969
1970              In order to elicit more verbose output, use -v.
1971
1972       zsocket -a [ -tv ] [ -d targetfd ] listenfd
1973              zsocket -a will accept an  incoming  connection  to  the  socket
1974              associated with listenfd.  The shell parameter REPLY will be set
1975              to the file descriptor associated with the inbound connection.
1976
1977              If -d is specified, its argument will be  taken  as  the  target
1978              file descriptor for the connection.
1979
1980              If  -t  is specified, zsocket will return if no incoming connec‐
1981              tion is pending.  Otherwise it will wait for one.
1982
1983              In order to elicit more verbose output, use -v.
1984

THE ZSH/STAT MODULE

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

THE ZSH/SYSTEM MODULE

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

THE ZSH/NET/TCP MODULE

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

THE ZSH/TERMCAP MODULE

2493       The zsh/termcap module makes available one builtin command:
2494
2495       echotc cap [ arg ... ]
2496              Output  the  termcap  value corresponding to the capability cap,
2497              with optional arguments.
2498
2499       The zsh/termcap module makes available one parameter:
2500
2501       termcap
2502              An associative array that maps termcap capability codes to their
2503              values.
2504

THE ZSH/TERMINFO MODULE

2506       The zsh/terminfo module makes available one builtin command:
2507
2508       echoti cap [ arg ]
2509              Output  the  terminfo value corresponding to the capability cap,
2510              instantiated with arg if applicable.
2511
2512       The zsh/terminfo module makes available one parameter:
2513
2514       terminfo
2515              An associative array that  maps  terminfo  capability  names  to
2516              their values.
2517

THE ZSH/ZFTP MODULE

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

THE ZSH/ZLE MODULE

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

THE ZSH/ZLEPARAMETER MODULE

2971       The  zsh/zleparameter module defines two special parameters that can be
2972       used to access internal information of the Zsh Line  Editor  (see  zsh‐
2973       zle(1)).
2974
2975       keymaps
2976              This array contains the names of the keymaps currently defined.
2977
2978       widgets
2979              This  associative  array contains one entry per widget. The name
2980              of the widget is the key and the value gives  information  about
2981              the widget. It is either
2982                the string `builtin' for builtin widgets,
2983                a string of the form `user:name' for user-defined widgets,
2984                  where  name  is  the name of the shell function implementing
2985              the widget,
2986                a string of the form `completion:type:name'
2987                  for completion widgets,
2988                or a null value if the widget is not yet  fully  defined.   In
2989              the penultimate case, type is the name of the builtin widget the
2990              completion widget imitates in its behavior and name is the  name
2991              of the shell function implementing the completion widget.
2992

THE ZSH/ZPROF MODULE

2994       When  loaded, the zsh/zprof causes shell functions to be profiled.  The
2995       profiling results can be obtained with the zprof builtin  command  made
2996       available  by this module.  There is no way to turn profiling off other
2997       than unloading the module.
2998
2999       zprof [ -c ]
3000              Without the -c option, zprof lists profiling results to standard
3001              output.   The  format  is  comparable  to  that of commands like
3002              gprof.
3003
3004              At the top there is a summary listing all  functions  that  were
3005              called  at  least  once.   This  summary is sorted in decreasing
3006              order of the amount of time spent in each.   The  lines  contain
3007              the  number  of  the  function  in order, which is used in other
3008              parts of the list in suffixes of the form `[num]', then the num‐
3009              ber  of calls made to the function.  The next three columns list
3010              the time in milliseconds spent in the function and  its  descen‐
3011              dants,  the  average  time in milliseconds spent in the function
3012              and its descendants per call and the percentage of time spent in
3013              all  shell  functions used in this function and its descendants.
3014              The following three  columns  give  the  same  information,  but
3015              counting  only the time spent in the function itself.  The final
3016              column shows the name of the function.
3017
3018              After the summary, detailed  information  about  every  function
3019              that  was  invoked  is listed, sorted in decreasing order of the
3020              amount of time spent in each function and its descendants.  Each
3021              of these entries consists of descriptions for the functions that
3022              called the function described,  the  function  itself,  and  the
3023              functions  that  were  called  from it.  The description for the
3024              function itself has the same format as in the summary (and shows
3025              the same information).  The other lines don't show the number of
3026              the function at the beginning  and  have  their  function  named
3027              indented  to  make it easier to distinguish the line showing the
3028              function described in the section from the surrounding lines.
3029
3030              The information shown in this case is almost the same as in  the
3031              summary,  but only refers to the call hierarchy being displayed.
3032              For example, for a calling function the column showing the total
3033              running  time lists the time spent in the described function and
3034              its descendants only for the times when it was called from  that
3035              particular  calling  function.  Likewise, for a called function,
3036              this columns lists the total time spent in the  called  function
3037              and  its  descendants only for the times when it was called from
3038              the function described.
3039
3040              Also in this case, the column showing the number of calls  to  a
3041              function also shows a slash and then the total number of invoca‐
3042              tions made to the called function.
3043
3044              As long as the zsh/zprof module is  loaded,  profiling  will  be
3045              done  and multiple invocations of the zprof builtin command will
3046              show the times and numbers of calls since the module was loaded.
3047              With  the  -c  option,  the zprof builtin command will reset its
3048              internal counters and will not show the listing.
3049

THE ZSH/ZPTY MODULE

3051       The zsh/zpty module offers one builtin:
3052
3053       zpty [ -e ] [ -b ] name [ arg ... ]
3054              The  arguments  following  name  are  concatenated  with  spaces
3055              between,  then  executed  as a command, as if passed to the eval
3056              builtin.  The command runs under a newly assigned  pseudo-termi‐
3057              nal; this is useful for running commands non-interactively which
3058              expect an interactive environment.  The name is not part of  the
3059              command,  but is used to refer to this command in later calls to
3060              zpty.
3061
3062              With the -e option, the pseudo-terminal is set up so that  input
3063              characters are echoed.
3064
3065              With the -b option, input to and output from the pseudo-terminal
3066              are made non-blocking.
3067
3068              The shell parameter REPLY is set to the file descriptor assigned
3069              to the master side of the pseudo-terminal.  This allows the ter‐
3070              minal to be monitored with ZLE  descriptor  handlers  (see  zsh‐
3071              zle(1))  or  manipulated  with  sysread  and  syswrite  (see THE
3072              ZSH/SYSTEM MODULE in zshmodules(1)).  Warning:  Use  of  sysread
3073              and  syswrite is not recommended, use zpty -r and zpty -w unless
3074              you know exactly what you are doing.
3075
3076       zpty -d [ name ... ]
3077              The second form, with the -d option, is used to delete  commands
3078              previously  started,  by supplying a list of their names.  If no
3079              name is given, all commands are  deleted.   Deleting  a  command
3080              causes the HUP signal to be sent to the corresponding process.
3081
3082       zpty -w [ -n ] name [ string ... ]
3083              The  -w option can be used to send the to command name the given
3084              strings as input (separated by spaces).  If the -n option is not
3085              given, a newline is added at the end.
3086
3087              If  no  string  is provided, the standard input is copied to the
3088              pseudo-terminal; this may stop before copying the full input  if
3089              the  pseudo-terminal is non-blocking.  The exact input is always
3090              copied: the -n option is not applied.
3091
3092              Note that the command under the pseudo-terminal sees this  input
3093              as  if  it were typed, so beware when sending special tty driver
3094              characters such as word-erase, line-kill, and end-of-file.
3095
3096       zpty -r [ -mt ] name [ param [ pattern ] ]
3097              The -r option can be used to read  the  output  of  the  command
3098              name.   With  only a name argument, the output read is copied to
3099              the standard output.  Unless the pseudo-terminal  is  non-block‐
3100              ing, copying continues until the command under the pseudo-termi‐
3101              nal exits; when non-blocking, only as much output as is  immedi‐
3102              ately  available  is  copied.   The return status is zero if any
3103              output is copied.
3104
3105              When also given a param argument, at most one line is  read  and
3106              stored  in the parameter named param.  Less than a full line may
3107              be read if the pseudo-terminal is non-blocking.  The return sta‐
3108              tus is zero if at least one character is stored in param.
3109
3110              If  a  pattern  is given as well, output is read until the whole
3111              string read matches the pattern, even in the non-blocking  case.
3112              The  return  status  is zero if the string read matches the pat‐
3113              tern, or if the command has exited but at  least  one  character
3114              could  still  be  read.  If the option -m is present, the return
3115              status is zero only if the pattern matches.  As of this writing,
3116              a maximum of one megabyte of output can be consumed this way; if
3117              a full megabyte is read without matching the pattern, the return
3118              status is non-zero.
3119
3120              In  all cases, the return status is non-zero if nothing could be
3121              read, and is 2 if this is because the command has finished.
3122
3123              If the -r option is combined with  the  -t  option,  zpty  tests
3124              whether output is available before trying to read.  If no output
3125              is available, zpty immediately returns the status 1.  When  used
3126              with  a  pattern,  the  behaviour on a failed poll is similar to
3127              when the command has exited:  the return value  is  zero  if  at
3128              least  one  character  could  still  be read even if the pattern
3129              failed to match.
3130
3131       zpty -t name
3132              The -t option without the -r option can be used to test  whether
3133              the  command name is still running.  It returns a zero status if
3134              the command is running and a non-zero value otherwise.
3135
3136       zpty [ -L ]
3137              The last form, without any arguments, is used to list  the  com‐
3138              mands  currently  defined.   If  the -L option is given, this is
3139              done in the form of calls to the zpty builtin.
3140

THE ZSH/ZSELECT MODULE

3142       The zsh/zselect module makes available one builtin command:
3143
3144       zselect [ -rwe ] [ -t timeout ] [ -a array ] [ -A assoc ] [ fd ... ]
3145              The zselect builtin is a front-end to the `select' system  call,
3146              which  blocks  until  a  file descriptor is ready for reading or
3147              writing, or has an error condition, with  an  optional  timeout.
3148              If  this  is not available on your system, the command prints an
3149              error message and returns status 2 (normal errors return  status
3150              1).   For  more  information, see your systems documentation for
3151              select(3).  Note there is no connection with the  shell  builtin
3152              of the same name.
3153
3154              Arguments   and  options  may  be  intermingled  in  any  order.
3155              Non-option arguments are file descriptors, which must be decimal
3156              integers.   By  default,  file  descriptors are to be tested for
3157              reading, i.e. zselect will return when data is available  to  be
3158              read  from  the  file descriptor, or more precisely, when a read
3159              operation from the file descriptor will not block.  After a  -r,
3160              -w and -e, the given file descriptors are to be tested for read‐
3161              ing, writing, or error conditions.  These options and  an  arbi‐
3162              trary list of file descriptors may be given in any order.
3163
3164              (The presence of an `error condition' is not well defined in the
3165              documentation for many  implementations  of  the  select  system
3166              call.   According to recent versions of the POSIX specification,
3167              it is really an exception condition, of which the only  standard
3168              example  is out-of-band data received on a socket.  So zsh users
3169              are unlikely to find the -e option useful.)
3170
3171              The option `-t timeout' specifies a timeout in hundredths  of  a
3172              second.   This  may  be zero, in which case the file descriptors
3173              will simply be polled and zselect will return  immediately.   It
3174              is  possible  to  call  zselect  with  no file descriptors and a
3175              non-zero timeout for use  as  a  finer-grained  replacement  for
3176              `sleep';  note,  however,  the  return  status is always 1 for a
3177              timeout.
3178
3179              The option `-a array' indicates that  array  should  be  set  to
3180              indicate  the file descriptor(s) which are ready.  If the option
3181              is not given, the array reply will be  used  for  this  purpose.
3182              The  array  will  contain  a string similar to the arguments for
3183              zselect.  For example,
3184
3185                     zselect -t 0 -r 0 -w 1
3186
3187              might return immediately with status 0 and $reply containing `-r
3188              0  -w  1'  to  show that both file descriptors are ready for the
3189              requested operations.
3190
3191              The option `-A assoc' indicates that the associative array assoc
3192              should  be  set  to  indicate  the  file descriptor(s) which are
3193              ready.  This option overrides the option -a, nor will  reply  be
3194              modified.   The  keys of assoc are the file descriptors, and the
3195              corresponding values are any of the characters `rwe' to indicate
3196              the condition.
3197
3198              The  command returns status 0 if some file descriptors are ready
3199              for reading.  If the operation timed out, or a timeout of 0  was
3200              given and no file descriptors were ready, or there was an error,
3201              it returns status 1 and the array will not be set (nor  modified
3202              in  any way).  If there was an error in the select operation the
3203              appropriate error message is printed.
3204

THE ZSH/ZUTIL MODULE

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