1ZSHBUILTINS(1) General Commands Manual ZSHBUILTINS(1)
2
3
4
6 zshbuiltins - zsh built-in commands
7
9 Some shell builtin commands take options as described in individual
10 entries; these are often referred to in the list below as `flags' to
11 avoid confusion with shell options, which may also have an effect on
12 the behaviour of builtin commands. In this introductory section,
13 `option' always has the meaning of an option to a command that should
14 be familiar to most command line users.
15
16 Typically, options are single letters preceded by a hyphen (-).
17 Options that take an argument accept it either immediately following
18 the option letter or after white space, for example `print -C3 {1..9}'
19 or `print -C 3 {1..9}' are equivalent. Arguments to options are not
20 the same as arguments to the command; the documentation indicates which
21 is which. Options that do not take an argument may be combined in a
22 single word, for example `print -rca -- *' and `print -r -c -a -- *'
23 are equivalent.
24
25 Some shell builtin commands also take options that begin with `+'
26 instead of `-'. The list below makes clear which commands these are.
27
28 Options (together with their individual arguments, if any) must appear
29 in a group before any non-option arguments; once the first non-option
30 argument has been found, option processing is terminated.
31
32 All builtin commands other than `echo' and precommand modifiers, even
33 those that have no options, can be given the argument `--' to terminate
34 option processing. This indicates that the following words are
35 non-option arguments, but is otherwise ignored. This is useful in
36 cases where arguments to the command may begin with `-'. For histori‐
37 cal reasons, most builtin commands (including `echo') also recognize a
38 single `-' in a separate word for this purpose; note that this is less
39 standard and use of `--' is recommended.
40
41 - simple command
42 See the section `Precommand Modifiers' in zshmisc(1).
43
44 . file [ arg ... ]
45 Read commands from file and execute them in the current shell
46 environment.
47
48 If file does not contain a slash, or if PATH_DIRS is set, the
49 shell looks in the components of $path to find the directory
50 containing file. Files in the current directory are not read
51 unless `.' appears somewhere in $path. If a file named
52 `file.zwc' is found, is newer than file, and is the compiled
53 form (created with the zcompile builtin) of file, then commands
54 are read from that file instead of file.
55
56 If any arguments arg are given, they become the positional
57 parameters; the old positional parameters are restored when the
58 file is done executing. However, if no arguments are given, the
59 positional parameters remain those of the calling context, and
60 no restoring is done.
61
62 If file was not found the return status is 127; if file was
63 found but contained a syntax error the return status is 126;
64 else the return status is the exit status of the last command
65 executed.
66
67 : [ arg ... ]
68 This command does nothing, although normal argument expansions
69 is performed which may have effects on shell parameters. A zero
70 exit status is returned.
71
72 alias [ {+|-}gmrsL ] [ name[=value] ... ]
73 For each name with a corresponding value, define an alias with
74 that value. A trailing space in value causes the next word to
75 be checked for alias expansion. If the -g flag is present,
76 define a global alias; global aliases are expanded even if they
77 do not occur in command position.
78
79 If the -s flag is present, define a suffix alias: if the command
80 word on a command line is in the form `text.name', where text is
81 any non-empty string, it is replaced by the text `value
82 text.name'. Note that name is treated as a literal string, not
83 a pattern. A trailing space in value is not special in this
84 case. For example,
85
86 alias -s ps='gv --'
87
88 will cause the command `*.ps' to be expanded to `gv -- *.ps'.
89 As alias expansion is carried out earlier than globbing, the
90 `*.ps' will then be expanded. Suffix aliases constitute a dif‐
91 ferent name space from other aliases (so in the above example it
92 is still possible to create an alias for the command ps) and the
93 two sets are never listed together.
94
95 For each name with no value, print the value of name, if any.
96 With no arguments, print all currently defined aliases other
97 than suffix aliases. If the -m flag is given the arguments are
98 taken as patterns (they should be quoted to preserve them from
99 being interpreted as glob patterns), and the aliases matching
100 these patterns are printed. When printing aliases and one of
101 the -g, -r or -s flags is present, restrict the printing to
102 global, regular or suffix aliases, respectively; a regular alias
103 is one which is neither a global nor a suffix alias. Using `+'
104 instead of `-', or ending the option list with a single `+',
105 prevents the values of the aliases from being printed.
106
107 If the -L flag is present, then print each alias in a manner
108 suitable for putting in a startup script. The exit status is
109 nonzero if a name (with no value) is given for which no alias
110 has been defined.
111
112 For more on aliases, include common problems, see the section
113 ALIASING in zshmisc(1).
114
115 autoload [ {+|-}RTUXdkmrtWz ] [ -w ] [ name ... ]
116 See the section `Autoloading Functions' in zshmisc(1) for full
117 details. The fpath parameter will be searched to find the func‐
118 tion definition when the function is first referenced.
119
120 If name consists of an absolute path, the function is defined to
121 load from the file given (searching as usual for dump files in
122 the given location). The name of the function is the basename
123 (non-directory part) of the file. It is normally an error if
124 the function is not found in the given location; however, if the
125 option -d is given, searching for the function defaults to
126 $fpath. If a function is loaded by absolute path, any functions
127 loaded from it that are marked for autoload without an absolute
128 path have the load path of the parent function temporarily
129 prepended to $fpath.
130
131 If the option -r or -R is given, the function is searched for
132 immediately and the location is recorded internally for use when
133 the function is executed; a relative path is expanded using the
134 value of $PWD. This protects against a change to $fpath after
135 the call to autoload. With -r, if the function is not found, it
136 is silently left unresolved until execution; with -R, an error
137 message is printed and command processing aborted immediately
138 the search fails, i.e. at the autoload command rather than at
139 function execution..
140
141 The flag -X may be used only inside a shell function. It causes
142 the calling function to be marked for autoloading and then imme‐
143 diately loaded and executed, with the current array of posi‐
144 tional parameters as arguments. This replaces the previous def‐
145 inition of the function. If no function definition is found, an
146 error is printed and the function remains undefined and marked
147 for autoloading. If an argument is given, it is used as a
148 directory (i.e. it does not include the name of the function) in
149 which the function is to be found; this may be combined with the
150 -d option to allow the function search to default to $fpath if
151 it is not in the given location.
152
153 The flag +X attempts to load each name as an autoloaded func‐
154 tion, but does not execute it. The exit status is zero (suc‐
155 cess) if the function was not previously defined and a defini‐
156 tion for it was found. This does not replace any existing defi‐
157 nition of the function. The exit status is nonzero (failure) if
158 the function was already defined or when no definition was
159 found. In the latter case the function remains undefined and
160 marked for autoloading. If ksh-style autoloading is enabled,
161 the function created will contain the contents of the file plus
162 a call to the function itself appended to it, thus giving normal
163 ksh autoloading behaviour on the first call to the function. If
164 the -m flag is also given each name is treated as a pattern and
165 all functions already marked for autoload that match the pattern
166 are loaded.
167
168 With the -t flag, turn on execution tracing; with -T, turn on
169 execution tracing only for the current function, turning it off
170 on entry to any called functions that do not also have tracing
171 enabled.
172
173 With the -U flag, alias expansion is suppressed when the func‐
174 tion is loaded.
175
176 With the -w flag, the names are taken as names of files compiled
177 with the zcompile builtin, and all functions defined in them are
178 marked for autoloading.
179
180 The flags -z and -k mark the function to be autoloaded using the
181 zsh or ksh style, as if the option KSH_AUTOLOAD were unset or
182 were set, respectively. The flags override the setting of the
183 option at the time the function is loaded.
184
185 Note that the autoload command makes no attempt to ensure the
186 shell options set during the loading or execution of the file
187 have any particular value. For this, the emulate command can be
188 used:
189
190 emulate zsh -c 'autoload -Uz func'
191
192 arranges that when func is loaded the shell is in native zsh
193 emulation, and this emulation is also applied when func is run.
194
195 Some of the functions of autoload are also provided by functions
196 -u or functions -U, but autoload is a more comprehensive inter‐
197 face.
198
199 bg [ job ... ]
200 job ... &
201 Put each specified job in the background, or the current job if
202 none is specified.
203
204 bindkey
205 See the section `Zle Builtins' in zshzle(1).
206
207 break [ n ]
208 Exit from an enclosing for, while, until, select or repeat loop.
209 If an arithmetic expression n is specified, then break n levels
210 instead of just one.
211
212 builtin name [ args ... ]
213 Executes the builtin name, with the given args.
214
215 bye Same as exit.
216
217 cap See the section `The zsh/cap Module' in zshmodules(1).
218
219 cd [ -qsLP ] [ arg ]
220 cd [ -qsLP ] old new
221 cd [ -qsLP ] {+|-}n
222 Change the current directory. In the first form, change the
223 current directory to arg, or to the value of $HOME if arg is not
224 specified. If arg is `-', change to the previous directory.
225
226 Otherwise, if arg begins with a slash, attempt to change to the
227 directory given by arg.
228
229 If arg does not begin with a slash, the behaviour depends on
230 whether the current directory `.' occurs in the list of directo‐
231 ries contained in the shell parameter cdpath. If it does not,
232 first attempt to change to the directory arg under the current
233 directory, and if that fails but cdpath is set and contains at
234 least one element attempt to change to the directory arg under
235 each component of cdpath in turn until successful. If `.'
236 occurs in cdpath, then cdpath is searched strictly in order so
237 that `.' is only tried at the appropriate point.
238
239 The order of testing cdpath is modified if the option POSIX_CD
240 is set, as described in the documentation for the option.
241
242 If no directory is found, the option CDABLE_VARS is set, and a
243 parameter named arg exists whose value begins with a slash,
244 treat its value as the directory. In that case, the parameter
245 is added to the named directory hash table.
246
247 The second form of cd substitutes the string new for the string
248 old in the name of the current directory, and tries to change to
249 this new directory.
250
251 The third form of cd extracts an entry from the directory stack,
252 and changes to that directory. An argument of the form `+n'
253 identifies a stack entry by counting from the left of the list
254 shown by the dirs command, starting with zero. An argument of
255 the form `-n' counts from the right. If the PUSHD_MINUS option
256 is set, the meanings of `+' and `-' in this context are swapped.
257 If the POSIX_CD option is set, this form of cd is not recognised
258 and will be interpreted as the first form.
259
260 If the -q (quiet) option is specified, the hook function chpwd
261 and the functions in the array chpwd_functions are not called.
262 This is useful for calls to cd that do not change the environ‐
263 ment seen by an interactive user.
264
265 If the -s option is specified, cd refuses to change the current
266 directory if the given pathname contains symlinks. If the -P
267 option is given or the CHASE_LINKS option is set, symbolic links
268 are resolved to their true values. If the -L option is given
269 symbolic links are retained in the directory (and not resolved)
270 regardless of the state of the CHASE_LINKS option.
271
272 chdir Same as cd.
273
274 clone See the section `The zsh/clone Module' in zshmodules(1).
275
276 command [ -pvV ] simple command
277 The simple command argument is taken as an external command
278 instead of a function or builtin and is executed. If the
279 POSIX_BUILTINS option is set, builtins will also be executed but
280 certain special properties of them are suppressed. The -p flag
281 causes a default path to be searched instead of that in $path.
282 With the -v flag, command is similar to whence and with -V, it
283 is equivalent to whence -v.
284
285 See also the section `Precommand Modifiers' in zshmisc(1).
286
287 comparguments
288 See the section `The zsh/computil Module' in zshmodules(1).
289
290 compcall
291 See the section `The zsh/compctl Module' in zshmodules(1).
292
293 compctl
294 See the section `The zsh/compctl Module' in zshmodules(1).
295
296 compdescribe
297 See the section `The zsh/computil Module' in zshmodules(1).
298
299 compfiles
300 See the section `The zsh/computil Module' in zshmodules(1).
301
302 compgroups
303 See the section `The zsh/computil Module' in zshmodules(1).
304
305 compquote
306 See the section `The zsh/computil Module' in zshmodules(1).
307
308 comptags
309 See the section `The zsh/computil Module' in zshmodules(1).
310
311 comptry
312 See the section `The zsh/computil Module' in zshmodules(1).
313
314 compvalues
315 See the section `The zsh/computil Module' in zshmodules(1).
316
317 continue [ n ]
318 Resume the next iteration of the enclosing for, while, until,
319 select or repeat loop. If an arithmetic expression n is speci‐
320 fied, break out of n-1 loops and resume at the nth enclosing
321 loop.
322
323 declare
324 Same as typeset.
325
326 dirs [ -c ] [ arg ... ]
327 dirs [ -lpv ]
328 With no arguments, print the contents of the directory stack.
329 Directories are added to this stack with the pushd command, and
330 removed with the cd or popd commands. If arguments are speci‐
331 fied, load them onto the directory stack, replacing anything
332 that was there, and push the current directory onto the stack.
333
334 -c clear the directory stack.
335
336 -l print directory names in full instead of using of using ~
337 expressions (see Dynamic and Static named directories in
338 zshexpn(1)).
339
340 -p print directory entries one per line.
341
342 -v number the directories in the stack when printing.
343
344 disable [ -afmprs ] name ...
345 Temporarily disable the named hash table elements or patterns.
346 The default is to disable builtin commands. This allows you to
347 use an external command with the same name as a builtin command.
348 The -a option causes disable to act on regular or global
349 aliases. The -s option causes disable to act on suffix aliases.
350 The -f option causes disable to act on shell functions. The -r
351 options causes disable to act on reserved words. Without argu‐
352 ments all disabled hash table elements from the corresponding
353 hash table are printed. With the -m flag the arguments are
354 taken as patterns (which should be quoted to prevent them from
355 undergoing filename expansion), and all hash table elements from
356 the corresponding hash table matching these patterns are dis‐
357 abled. Disabled objects can be enabled with the enable command.
358
359 With the option -p, name ... refer to elements of the shell's
360 pattern syntax as described in the section `Filename Genera‐
361 tion'. Certain elements can be disabled separately, as given
362 below.
363
364 Note that patterns not allowed by the current settings for the
365 options EXTENDED_GLOB, KSH_GLOB and SH_GLOB are never enabled,
366 regardless of the setting here. For example, if EXTENDED_GLOB
367 is not active, the pattern ^ is ineffective even if `disable -p
368 "^"' has not been issued. The list below indicates any option
369 settings that restrict the use of the pattern. It should be
370 noted that setting SH_GLOB has a wider effect than merely dis‐
371 abling patterns as certain expressions, in particular those
372 involving parentheses, are parsed differently.
373
374 The following patterns may be disabled; all the strings need
375 quoting on the command line to prevent them from being inter‐
376 preted immediately as patterns and the patterns are shown below
377 in single quotes as a reminder.
378
379 '?' The pattern character ? wherever it occurs, including
380 when preceding a parenthesis with KSH_GLOB.
381
382 '*' The pattern character * wherever it occurs, including
383 recursive globbing and when preceding a parenthesis with
384 KSH_GLOB.
385
386 '[' Character classes.
387
388 '<' (NO_SH_GLOB)
389 Numeric ranges.
390
391 '|' (NO_SH_GLOB)
392 Alternation in grouped patterns, case statements, or
393 KSH_GLOB parenthesised expressions.
394
395 '(' (NO_SH_GLOB)
396 Grouping using single parentheses. Disabling this does
397 not disable the use of parentheses for KSH_GLOB where
398 they are introduced by a special character, nor for glob
399 qualifiers (use `setopt NO_BARE_GLOB_QUAL' to disable
400 glob qualifiers that use parentheses only).
401
402 '~' (EXTENDED_GLOB)
403 Exclusion in the form A~B.
404
405 '^' (EXTENDED_GLOB)
406 Exclusion in the form A^B.
407
408 '#' (EXTENDED_GLOB)
409 The pattern character # wherever it occurs, both for rep‐
410 etition of a previous pattern and for indicating globbing
411 flags.
412
413 '?(' (KSH_GLOB)
414 The grouping form ?(...). Note this is also disabled if
415 '?' is disabled.
416
417 '*(' (KSH_GLOB)
418 The grouping form *(...). Note this is also disabled if
419 '*' is disabled.
420
421 '+(' (KSH_GLOB)
422 The grouping form +(...).
423
424 '!(' (KSH_GLOB)
425 The grouping form !(...).
426
427 '@(' (KSH_GLOB)
428 The grouping form @(...).
429
430 disown [ job ... ]
431 job ... &|
432 job ... &!
433 Remove the specified jobs from the job table; the shell will no
434 longer report their status, and will not complain if you try to
435 exit an interactive shell with them running or stopped. If no
436 job is specified, disown the current job.
437
438 If the jobs are currently stopped and the AUTO_CONTINUE option
439 is not set, a warning is printed containing information about
440 how to make them running after they have been disowned. If one
441 of the latter two forms is used, the jobs will automatically be
442 made running, independent of the setting of the AUTO_CONTINUE
443 option.
444
445 echo [ -neE ] [ arg ... ]
446 Write each arg on the standard output, with a space separating
447 each one. If the -n flag is not present, print a newline at the
448 end. echo recognizes the following escape sequences:
449
450 \a bell character
451 \b backspace
452 \c suppress subsequent characters and final newline
453 \e escape
454 \f form feed
455 \n linefeed (newline)
456 \r carriage return
457 \t horizontal tab
458 \v vertical tab
459 \\ backslash
460 \0NNN character code in octal
461 \xNN character code in hexadecimal
462 \uNNNN unicode character code in hexadecimal
463 \UNNNNNNNN
464 unicode character code in hexadecimal
465
466 The -E flag, or the BSD_ECHO option, can be used to disable
467 these escape sequences. In the latter case, -e flag can be used
468 to enable them.
469
470 Note that for standards compliance a double dash does not termi‐
471 nate option processing; instead, it is printed directly. How‐
472 ever, a single dash does terminate option processing, so the
473 first dash, possibly following options, is not printed, but
474 everything following it is printed as an argument. The single
475 dash behaviour is different from other shells. For a more por‐
476 table way of printing text, see printf, and for a more control‐
477 lable way of printing text within zsh, see print.
478
479 echotc See the section `The zsh/termcap Module' in zshmodules(1).
480
481 echoti See the section `The zsh/terminfo Module' in zshmodules(1).
482
483 emulate [ -lLR ] [ {zsh|sh|ksh|csh} [ flags ... ] ]
484 Without any argument print current emulation mode.
485
486 With single argument set up zsh options to emulate the specified
487 shell as much as possible. csh will never be fully emulated.
488 If the argument is not one of the shells listed above, zsh will
489 be used as a default; more precisely, the tests performed on the
490 argument are the same as those used to determine the emulation
491 at startup based on the shell name, see the section COMPATIBIL‐
492 ITY in zsh(1) . In addition to setting shell options, the com‐
493 mand also restores the pristine state of pattern enables, as if
494 all patterns had been enabled using enable -p.
495
496 If the emulate command occurs inside a function that has been
497 marked for execution tracing with functions -t then the xtrace
498 option will be turned on regardless of emulation mode or other
499 options. Note that code executed inside the function by the .,
500 source, or eval commands is not considered to be running
501 directly from the function, hence does not provoke this behav‐
502 iour.
503
504 If the -R switch is given, all settable options are reset to
505 their default value corresponding to the specified emulation
506 mode, except for certain options describing the interactive
507 environment; otherwise, only those options likely to cause
508 portability problems in scripts and functions are altered. If
509 the -L switch is given, the options LOCAL_OPTIONS, LOCAL_PAT‐
510 TERNS and LOCAL_TRAPS will be set as well, causing the effects
511 of the emulate command and any setopt, disable -p or enable -p,
512 and trap commands to be local to the immediately surrounding
513 shell function, if any; normally these options are turned off in
514 all emulation modes except ksh. The -L switch is mutually exclu‐
515 sive with the use of -c in flags.
516
517 If there is a single argument and the -l switch is given, the
518 options that would be set or unset (the latter indicated with
519 the prefix `no') are listed. -l can be combined with -L or -R
520 and the list will be modified in the appropriate way. Note the
521 list does not depend on the current setting of options, i.e. it
522 includes all options that may in principle change, not just
523 those that would actually change.
524
525 The flags may be any of the invocation-time flags described in
526 the section INVOCATION in zsh(1), except that `-o EMACS' and `-o
527 VI' may not be used. Flags such as `+r'/`+o RESTRICTED' may be
528 prohibited in some circumstances.
529
530 If -c arg appears in flags, arg is evaluated while the requested
531 emulation is temporarily in effect. In this case the emulation
532 mode and all options are restored to their previous values
533 before emulate returns. The -R switch may precede the name of
534 the shell to emulate; note this has a meaning distinct from
535 including -R in flags.
536
537 Use of -c enables `sticky' emulation mode for functions defined
538 within the evaluated expression: the emulation mode is associ‐
539 ated thereafter with the function so that whenever the function
540 is executed the emulation (respecting the -R switch, if present)
541 and all options are set (and pattern disables cleared) before
542 entry to the function, and the state is restored after exit. If
543 the function is called when the sticky emulation is already in
544 effect, either within an `emulate shell -c' expression or within
545 another function with the same sticky emulation, entry and exit
546 from the function do not cause options to be altered (except due
547 to standard processing such as the LOCAL_OPTIONS option). This
548 also applies to functions marked for autoload within the sticky
549 emulation; the appropriate set of options will be applied at the
550 point the function is loaded as well as when it is run.
551
552 For example:
553
554 emulate sh -c 'fni() { setopt cshnullglob; }
555 fno() { fni; }'
556 fno
557
558 The two functions fni and fno are defined with sticky sh emula‐
559 tion. fno is then executed, causing options associated with
560 emulations to be set to their values in sh. fno then calls fni;
561 because fni is also marked for sticky sh emulation, no option
562 changes take place on entry to or exit from it. Hence the
563 option cshnullglob, turned off by sh emulation, will be turned
564 on within fni and remain on return to fno. On exit from fno,
565 the emulation mode and all options will be restored to the state
566 they were in before entry to the temporary emulation.
567
568 The documentation above is typically sufficient for the intended
569 purpose of executing code designed for other shells in a suit‐
570 able environment. More detailed rules follow.
571 1. The sticky emulation environment provided by `emulate
572 shell -c' is identical to that provided by entry to a
573 function marked for sticky emulation as a consequence of
574 being defined in such an environment. Hence, for exam‐
575 ple, the sticky emulation is inherited by subfunctions
576 defined within functions with sticky emulation.
577 2. No change of options takes place on entry to or exit from
578 functions that are not marked for sticky emulation, other
579 than those that would normally take place, even if those
580 functions are called within sticky emulation.
581 3. No special handling is provided for functions marked for
582 autoload nor for functions present in wordcode created by
583 the zcompile command.
584 4. The presence or absence of the -R switch to emulate cor‐
585 responds to different sticky emulation modes, so for
586 example `emulate sh -c', `emulate -R sh -c' and `emulate
587 csh -c' are treated as three distinct sticky emulations.
588 5. Difference in shell options supplied in addition to the
589 basic emulation also mean the sticky emulations are dif‐
590 ferent, so for example `emulate zsh -c' and `emulate zsh
591 -o cbases -c' are treated as distinct sticky emulations.
592
593 enable [ -afmprs ] name ...
594 Enable the named hash table elements, presumably disabled ear‐
595 lier with disable. The default is to enable builtin commands.
596 The -a option causes enable to act on regular or global aliases.
597 The -s option causes enable to act on suffix aliases. The -f
598 option causes enable to act on shell functions. The -r option
599 causes enable to act on reserved words. Without arguments all
600 enabled hash table elements from the corresponding hash table
601 are printed. With the -m flag the arguments are taken as pat‐
602 terns (should be quoted) and all hash table elements from the
603 corresponding hash table matching these patterns are enabled.
604 Enabled objects can be disabled with the disable builtin com‐
605 mand.
606
607 enable -p reenables patterns disabled with disable -p. Note
608 that it does not override globbing options; for example, `enable
609 -p "~"' does not cause the pattern character ~ to be active
610 unless the EXTENDED_GLOB option is also set. To enable all pos‐
611 sible patterns (so that they may be individually disabled with
612 disable -p), use `setopt EXTENDED_GLOB KSH_GLOB NO_SH_GLOB'.
613
614 eval [ arg ... ]
615 Read the arguments as input to the shell and execute the result‐
616 ing command(s) in the current shell process. The return status
617 is the same as if the commands had been executed directly by the
618 shell; if there are no args or they contain no commands (i.e.
619 are an empty string or whitespace) the return status is zero.
620
621 exec [ -cl ] [ -a argv0 ] [ command [ arg ... ] ]
622 Replace the current shell with command rather than forking. If
623 command is a shell builtin command or a shell function, the
624 shell executes it, and exits when the command is complete.
625
626 With -c clear the environment; with -l prepend - to the argv[0]
627 string of the command executed (to simulate a login shell); with
628 -a argv0 set the argv[0] string of the command executed. See
629 the section `Precommand Modifiers' in zshmisc(1).
630
631 If the option POSIX_BUILTINS is set, command is never inter‐
632 preted as a shell builtin command or shell function. This means
633 further precommand modifiers such as builtin and noglob are also
634 not interpreted within the shell. Hence command is always found
635 by searching the command path.
636
637 If command is omitted but any redirections are specified, then
638 the redirections will take effect in the current shell.
639
640 exit [ n ]
641 Exit the shell with the exit status specified by an arithmetic
642 expression n; if none is specified, use the exit status from the
643 last command executed. An EOF condition will also cause the
644 shell to exit, unless the IGNORE_EOF option is set.
645
646 See notes at the end of the section JOBS in zshmisc(1) for some
647 possibly unexpected interactions of the exit command with jobs.
648
649 export [ name[=value] ... ]
650 The specified names are marked for automatic export to the envi‐
651 ronment of subsequently executed commands. Equivalent to type‐
652 set -gx. If a parameter specified does not already exist, it is
653 created in the global scope.
654
655 false [ arg ... ]
656 Do nothing and return an exit status of 1.
657
658
659 fc [ -e ename ] [ -LI ] [ -m match ] [ old=new ... ] [ first [ last ] ]
660 fc -l [ -LI ] [ -nrdfEiD ] [ -t timefmt ] [ -m match ]
661 [ old=new ... ] [ first [ last ] ]
662 fc -p [ -a ] [ filename [ histsize [ savehistsize ] ] ]
663 fc -P
664 fc -ARWI [ filename ]
665 The fc command controls the interactive history mechanism. Note
666 that reading and writing of history options is only performed if
667 the shell is interactive. Usually this is detected automati‐
668 cally, but it can be forced by setting the interactive option
669 when starting the shell.
670
671 The first two forms of this command select a range of events
672 from first to last from the history list. The arguments first
673 and last may be specified as a number or as a string. A nega‐
674 tive number is used as an offset to the current history event
675 number. A string specifies the most recent event beginning with
676 the given string. All substitutions old=new, if any, are then
677 performed on the text of the events.
678
679 In addition to the number range,
680 -I restricts to only internal events (not from $HISTFILE)
681 -L restricts to only local events (not from other shells,
682 see SHARE_HISTORY in zshoptions(1) -- note that $HISTFILE
683 is considered local when read at startup)
684 -m takes the first argument as a pattern (should be quoted)
685 and only the history events matching this pattern are
686 considered
687
688 If first is not specified, it will be set to -1 (the most recent
689 event), or to -16 if the -l flag is given. If last is not spec‐
690 ified, it will be set to first, or to -1 if the -l flag is
691 given. However, if the current event has added entries to the
692 history with `print -s' or `fc -R', then the default last for -l
693 includes all new history entries since the current event began.
694
695 When the -l flag is given, the resulting events are listed on
696 standard output. Otherwise the editor program specified by -e
697 ename is invoked on a file containing these history events. If
698 -e is not given, the value of the parameter FCEDIT is used; if
699 that is not set the value of the parameter EDITOR is used; if
700 that is not set a builtin default, usually `vi' is used. If
701 ename is `-', no editor is invoked. When editing is complete,
702 the edited command is executed.
703
704 The flag -r reverses the order of the events and the flag -n
705 suppresses event numbers when listing.
706
707 Also when listing,
708 -d prints timestamps for each event
709 -f prints full time-date stamps in the US `MM/DD/YY hh:mm'
710 format
711 -E prints full time-date stamps in the European `dd.mm.yyyy
712 hh:mm' format
713 -i prints full time-date stamps in ISO8601 `yyyy-mm-dd
714 hh:mm' format
715 -t fmt prints time and date stamps in the given format; fmt is
716 formatted with the strftime function with the zsh exten‐
717 sions described for the %D{string} prompt format in the
718 section EXPANSION OF PROMPT SEQUENCES in zshmisc(1). The
719 resulting formatted string must be no more than 256 char‐
720 acters or will not be printed
721 -D prints elapsed times; may be combined with one of the
722 options above
723
724 `fc -p' pushes the current history list onto a stack and
725 switches to a new history list. If the -a option is also speci‐
726 fied, this history list will be automatically popped when the
727 current function scope is exited, which is a much better solu‐
728 tion than creating a trap function to call `fc -P' manually. If
729 no arguments are specified, the history list is left empty,
730 $HISTFILE is unset, and $HISTSIZE & $SAVEHIST are set to their
731 default values. If one argument is given, $HISTFILE is set to
732 that filename, $HISTSIZE & $SAVEHIST are left unchanged, and the
733 history file is read in (if it exists) to initialize the new
734 list. If a second argument is specified, $HISTSIZE & $SAVEHIST
735 are instead set to the single specified numeric value. Finally,
736 if a third argument is specified, $SAVEHIST is set to a separate
737 value from $HISTSIZE. You are free to change these environment
738 values for the new history list however you desire in order to
739 manipulate the new history list.
740
741 `fc -P' pops the history list back to an older list saved by `fc
742 -p'. The current list is saved to its $HISTFILE before it is
743 destroyed (assuming that $HISTFILE and $SAVEHIST are set appro‐
744 priately, of course). The values of $HISTFILE, $HISTSIZE, and
745 $SAVEHIST are restored to the values they had when `fc -p' was
746 called. Note that this restoration can conflict with making
747 these variables "local", so your best bet is to avoid local dec‐
748 larations for these variables in functions that use `fc -p'.
749 The one other guaranteed-safe combination is declaring these
750 variables to be local at the top of your function and using the
751 automatic option (-a) with `fc -p'. Finally, note that it is
752 legal to manually pop a push marked for automatic popping if you
753 need to do so before the function exits.
754
755 `fc -R' reads the history from the given file, `fc -W' writes
756 the history out to the given file, and `fc -A' appends the his‐
757 tory out to the given file. If no filename is specified, the
758 $HISTFILE is assumed. If the -I option is added to -R, only
759 those events that are not already contained within the internal
760 history list are added. If the -I option is added to -A or -W,
761 only those events that are new since last incremental
762 append/write to the history file are appended/written. In any
763 case, the created file will have no more than $SAVEHIST entries.
764
765 fg [ job ... ]
766 job ...
767 Bring each specified job in turn to the foreground. If no job
768 is specified, resume the current job.
769
770 float [ {+|-}Hghlprtux ] [ {+|-}EFLRZ [ n ] ] [ name[=value] ... ]
771 Equivalent to typeset -E, except that options irrelevant to
772 floating point numbers are not permitted.
773
774 functions [ {+|-}UkmtTuWz ] [ -x num ] [ name ... ]
775 functions -c oldfn newfn
776 functions -M [-s] mathfn [ min [ max [ shellfn ] ] ]
777 functions -M [ -m pattern ... ]
778 functions +M [ -m ] mathfn ...
779 Equivalent to typeset -f, with the exception of the -c, -x, -M
780 and -W options. For functions -u and functions -U, see
781 autoload, which provides additional options.
782
783 The -x option indicates that any functions output will have each
784 leading tab for indentation, added by the shell to show syntac‐
785 tic structure, expanded to the given number num of spaces. num
786 can also be 0 to suppress all indentation.
787
788 The -W option turns on the option WARN_NESTED_VAR for the named
789 function or functions only. The option is turned off at the
790 start of nested functions (apart from anonoymous functions)
791 unless the called function also has the -W attribute.
792
793 The -c option causes oldfn to be copied to newfn. The copy is
794 efficiently handled internally by reference counting. If oldfn
795 was marked for autoload it is first loaded and if this fails the
796 copy fails. Either function may subsequently be redefined with‐
797 out affecting the other. A typical idiom is that oldfn is the
798 name of a library shell function which is then redefined to call
799 newfn, thereby installing a modified version of the function.
800
801 Use of the -M option may not be combined with any of the options
802 handled by typeset -f.
803
804 functions -M mathfn defines mathfn as the name of a mathematical
805 function recognised in all forms of arithmetical expressions;
806 see the section `Arithmetic Evaluation' in zshmisc(1). By
807 default mathfn may take any number of comma-separated arguments.
808 If min is given, it must have exactly min args; if min and max
809 are both given, it must have at least min and at most max args.
810 max may be -1 to indicate that there is no upper limit.
811
812 By default the function is implemented by a shell function of
813 the same name; if shellfn is specified it gives the name of the
814 corresponding shell function while mathfn remains the name used
815 in arithmetical expressions. The name of the function in $0 is
816 mathfn (not shellfn as would usually be the case), provided the
817 option FUNCTION_ARGZERO is in effect. The positional parameters
818 in the shell function correspond to the arguments of the mathe‐
819 matical function call. The result of the last arithmetical
820 expression evaluated inside the shell function (even if it is a
821 form that normally only returns a status) gives the result of
822 the mathematical function.
823
824 If the additional option -s is given to functions -M, the argu‐
825 ment to the function is a single string: anything between the
826 opening and matching closing parenthesis is passed to the func‐
827 tion as a single argument, even if it includes commas or white
828 space. The minimum and maximum argument specifiers must there‐
829 fore be 1 if given. An empty argument list is passed as a
830 zero-length string.
831
832 functions -M with no arguments lists all such user-defined func‐
833 tions in the same form as a definition. With the additional
834 option -m and a list of arguments, all functions whose mathfn
835 matches one of the pattern arguments are listed.
836
837 function +M removes the list of mathematical functions; with the
838 additional option -m the arguments are treated as patterns and
839 all functions whose mathfn matches the pattern are removed.
840 Note that the shell function implementing the behaviour is not
841 removed (regardless of whether its name coincides with mathfn).
842
843 For example, the following prints the cube of 3:
844
845 zmath_cube() { (( $1 * $1 * $1 )) }
846 functions -M cube 1 1 zmath_cube
847 print $(( cube(3) ))
848
849 The following string function takes a single argument, including
850 the commas, so prints 11:
851
852 stringfn() { (( $#1 )) }
853 functions -Ms stringfn
854 print $(( stringfn(foo,bar,rod) ))
855
856 getcap See the section `The zsh/cap Module' in zshmodules(1).
857
858 getln [ -AclneE ] name ...
859 Read the top value from the buffer stack and put it in the shell
860 parameter name. Equivalent to read -zr.
861
862 getopts optstring name [ arg ... ]
863 Checks the args for legal options. If the args are omitted, use
864 the positional parameters. A valid option argument begins with
865 a `+' or a `-'. An argument not beginning with a `+' or a `-',
866 or the argument `--', ends the options. Note that a single `-'
867 is not considered a valid option argument. optstring contains
868 the letters that getopts recognizes. If a letter is followed by
869 a `:', that option requires an argument. The options can be
870 separated from the argument by blanks.
871
872 Each time it is invoked, getopts places the option letter it
873 finds in the shell parameter name, prepended with a `+' when arg
874 begins with a `+'. The index of the next arg is stored in
875 OPTIND. The option argument, if any, is stored in OPTARG.
876
877 The first option to be examined may be changed by explicitly
878 assigning to OPTIND. OPTIND has an initial value of 1, and is
879 normally set to 1 upon entry to a shell function and restored
880 upon exit (this is disabled by the POSIX_BUILTINS option).
881 OPTARG is not reset and retains its value from the most recent
882 call to getopts. If either of OPTIND or OPTARG is explicitly
883 unset, it remains unset, and the index or option argument is not
884 stored. The option itself is still stored in name in this case.
885
886 A leading `:' in optstring causes getopts to store the letter of
887 any invalid option in OPTARG, and to set name to `?' for an
888 unknown option and to `:' when a required argument is missing.
889 Otherwise, getopts sets name to `?' and prints an error message
890 when an option is invalid. The exit status is nonzero when
891 there are no more options.
892
893 hash [ -Ldfmrv ] [ name[=value] ] ...
894 hash can be used to directly modify the contents of the command
895 hash table, and the named directory hash table. Normally one
896 would modify these tables by modifying one's PATH (for the com‐
897 mand hash table) or by creating appropriate shell parameters
898 (for the named directory hash table). The choice of hash table
899 to work on is determined by the -d option; without the option
900 the command hash table is used, and with the option the named
901 directory hash table is used.
902
903 A command name starting with a / is never hashed, whether by
904 explicit use of the hash command or otherwise. Such a command
905 is always found by direct look up in the file system.
906
907 Given no arguments, and neither the -r or -f options, the
908 selected hash table will be listed in full.
909
910 The -r option causes the selected hash table to be emptied. It
911 will be subsequently rebuilt in the normal fashion. The -f
912 option causes the selected hash table to be fully rebuilt imme‐
913 diately. For the command hash table this hashes all the abso‐
914 lute directories in the PATH, and for the named directory hash
915 table this adds all users' home directories. These two options
916 cannot be used with any arguments.
917
918 The -m option causes the arguments to be taken as patterns
919 (which should be quoted) and the elements of the hash table
920 matching those patterns are printed. This is the only way to
921 display a limited selection of hash table elements.
922
923 For each name with a corresponding value, put `name' in the
924 selected hash table, associating it with the pathname `value'.
925 In the command hash table, this means that whenever `name' is
926 used as a command argument, the shell will try to execute the
927 file given by `value'. In the named directory hash table, this
928 means that `value' may be referred to as `~name'.
929
930 For each name with no corresponding value, attempt to add name
931 to the hash table, checking what the appropriate value is in the
932 normal manner for that hash table. If an appropriate value
933 can't be found, then the hash table will be unchanged.
934
935 The -v option causes hash table entries to be listed as they are
936 added by explicit specification. If has no effect if used with
937 -f.
938
939 If the -L flag is present, then each hash table entry is printed
940 in the form of a call to hash.
941
942 history
943 Same as fc -l.
944
945 integer [ {+|-}Hghlprtux ] [ {+|-}LRZi [ n ] ] [ name[=value] ... ]
946 Equivalent to typeset -i, except that options irrelevant to
947 integers are not permitted.
948
949 jobs [ -dlprs ] [ job ... ]
950 jobs -Z string
951 Lists information about each given job, or all jobs if job is
952 omitted. The -l flag lists process IDs, and the -p flag lists
953 process groups. If the -r flag is specified only running jobs
954 will be listed and if the -s flag is given only stopped jobs are
955 shown. If the -d flag is given, the directory from which the
956 job was started (which may not be the current directory of the
957 job) will also be shown.
958
959 The -Z option replaces the shell's argument and environment
960 space with the given string, truncated if necessary to fit.
961 This will normally be visible in ps (ps(1)) listings. This fea‐
962 ture is typically used by daemons, to indicate their state.
963
964 kill [ -s signal_name | -n signal_number | -sig ] job ...
965 kill -l [ sig ... ]
966 Sends either SIGTERM or the specified signal to the given jobs
967 or processes. Signals are given by number or by names, with or
968 without the `SIG' prefix. If the signal being sent is not
969 `KILL' or `CONT', then the job will be sent a `CONT' signal if
970 it is stopped. The argument job can be the process ID of a job
971 not in the job list. In the second form, kill -l, if sig is not
972 specified the signal names are listed. Otherwise, for each sig
973 that is a name, the corresponding signal number is listed. For
974 each sig that is a signal number or a number representing the
975 exit status of a process which was terminated or stopped by a
976 signal the name of the signal is printed.
977
978 On some systems, alternative signal names are allowed for a few
979 signals. Typical examples are SIGCHLD and SIGCLD or SIGPOLL and
980 SIGIO, assuming they correspond to the same signal number. kill
981 -l will only list the preferred form, however kill -l alt will
982 show if the alternative form corresponds to a signal number.
983 For example, under Linux kill -l IO and kill -l POLL both output
984 29, hence kill -IO and kill -POLL have the same effect.
985
986 Many systems will allow process IDs to be negative to kill a
987 process group or zero to kill the current process group.
988
989 let arg ...
990 Evaluate each arg as an arithmetic expression. See the section
991 `Arithmetic Evaluation' in zshmisc(1) for a description of
992 arithmetic expressions. The exit status is 0 if the value of
993 the last expression is nonzero, 1 if it is zero, and 2 if an
994 error occurred.
995
996 limit [ -hs ] [ resource [ limit ] ] ...
997 Set or display resource limits. Unless the -s flag is given,
998 the limit applies only the children of the shell. If -s is
999 given without other arguments, the resource limits of the cur‐
1000 rent shell is set to the previously set resource limits of the
1001 children.
1002
1003 If limit is not specified, print the current limit placed on
1004 resource, otherwise set the limit to the specified value. If
1005 the -h flag is given, use hard limits instead of soft limits.
1006 If no resource is given, print all limits.
1007
1008 When looping over multiple resources, the shell will abort imme‐
1009 diately if it detects a badly formed argument. However, if it
1010 fails to set a limit for some other reason it will continue try‐
1011 ing to set the remaining limits.
1012
1013 resource can be one of:
1014
1015 addressspace
1016 Maximum amount of address space used.
1017 aiomemorylocked
1018 Maximum amount of memory locked in RAM for AIO opera‐
1019 tions.
1020 aiooperations
1021 Maximum number of AIO operations.
1022 cachedthreads
1023 Maximum number of cached threads.
1024 coredumpsize
1025 Maximum size of a core dump.
1026 cputime
1027 Maximum CPU seconds per process.
1028 datasize
1029 Maximum data size (including stack) for each process.
1030 descriptors
1031 Maximum value for a file descriptor.
1032 filesize
1033 Largest single file allowed.
1034 kqueues
1035 Maximum number of kqueues allocated.
1036 maxproc
1037 Maximum number of processes.
1038 maxpthreads
1039 Maximum number of threads per process.
1040 memorylocked
1041 Maximum amount of memory locked in RAM.
1042 memoryuse
1043 Maximum resident set size.
1044 msgqueue
1045 Maximum number of bytes in POSIX message queues.
1046 posixlocks
1047 Maximum number of POSIX locks per user.
1048 pseudoterminals
1049 Maximum number of pseudo-terminals.
1050 resident
1051 Maximum resident set size.
1052 sigpending
1053 Maximum number of pending signals.
1054 sockbufsize
1055 Maximum size of all socket buffers.
1056 stacksize
1057 Maximum stack size for each process.
1058 swapsize
1059 Maximum amount of swap used.
1060 vmemorysize
1061 Maximum amount of virtual memory.
1062
1063 Which of these resource limits are available depends on the sys‐
1064 tem. resource can be abbreviated to any unambiguous prefix. It
1065 can also be an integer, which corresponds to the integer defined
1066 for the resource by the operating system.
1067
1068 If argument corresponds to a number which is out of the range of
1069 the resources configured into the shell, the shell will try to
1070 read or write the limit anyway, and will report an error if this
1071 fails. As the shell does not store such resources internally,
1072 an attempt to set the limit will fail unless the -s option is
1073 present.
1074
1075 limit is a number, with an optional scaling factor, as follows:
1076
1077 nh hours
1078 nk kilobytes (default)
1079 nm megabytes or minutes
1080 ng gigabytes
1081 [mm:]ss
1082 minutes and seconds
1083
1084 The limit command is not made available by default when the
1085 shell starts in a mode emulating another shell. It can be made
1086 available with the command `zmodload -F zsh/rlimits b:limit'.
1087
1088 local [ {+|-}AHUahlprtux ] [ {+|-}EFLRZi [ n ] ] [ name[=value] ... ]
1089 Same as typeset, except that the options -g, and -f are not per‐
1090 mitted. In this case the -x option does not force the use of
1091 -g, i.e. exported variables will be local to functions.
1092
1093 log List all users currently logged in who are affected by the cur‐
1094 rent setting of the watch parameter.
1095
1096 logout [ n ]
1097 Same as exit, except that it only works in a login shell.
1098
1099 noglob simple command
1100 See the section `Precommand Modifiers' in zshmisc(1).
1101
1102 popd [ -q ] [ {+|-}n ]
1103 Remove an entry from the directory stack, and perform a cd to
1104 the new top directory. With no argument, the current top entry
1105 is removed. An argument of the form `+n' identifies a stack
1106 entry by counting from the left of the list shown by the dirs
1107 command, starting with zero. An argument of the form -n counts
1108 from the right. If the PUSHD_MINUS option is set, the meanings
1109 of `+' and `-' in this context are swapped.
1110
1111 If the -q (quiet) option is specified, the hook function chpwd
1112 and the functions in the array $chpwd_functions are not called,
1113 and the new directory stack is not printed. This is useful for
1114 calls to popd that do not change the environment seen by an
1115 interactive user.
1116
1117 print [ -abcDilmnNoOpPrsSz ] [ -u n ] [ -f format ] [ -C cols ]
1118 [ -v name ] [ -xX tabstop ] [ -R [ -en ]] [ arg ... ]
1119 With the `-f' option the arguments are printed as described by
1120 printf. With no flags or with the flag `-', the arguments are
1121 printed on the standard output as described by echo, with the
1122 following differences: the escape sequence `\M-x' (or `\Mx')
1123 metafies the character x (sets the highest bit), `\C-x' (or
1124 `\Cx') produces a control character (`\C-@' and `\C-?' give the
1125 characters NULL and delete), a character code in octal is repre‐
1126 sented by `\NNN' (instead of `\0NNN'), and `\E' is a synonym for
1127 `\e'. Finally, if not in an escape sequence, `\' escapes the
1128 following character and is not printed.
1129
1130 -a Print arguments with the column incrementing first. Only
1131 useful with the -c and -C options.
1132
1133 -b Recognize all the escape sequences defined for the bind‐
1134 key command, see the section `Zle Builtins' in zshzle(1).
1135
1136 -c Print the arguments in columns. Unless -a is also given,
1137 arguments are printed with the row incrementing first.
1138
1139 -C cols
1140 Print the arguments in cols columns. Unless -a is also
1141 given, arguments are printed with the row incrementing
1142 first.
1143
1144 -D Treat the arguments as paths, replacing directory pre‐
1145 fixes with ~ expressions corresponding to directory
1146 names, as appropriate.
1147
1148 -i If given together with -o or -O, sorting is performed
1149 case-independently.
1150
1151 -l Print the arguments separated by newlines instead of spa‐
1152 ces. Note: if the list of arguments is empty, print -l
1153 will still output one empty line. To print a possi‐
1154 bly-empty list of arguments one per line, use print -C1,
1155 as in `print -rC1 -- "$list[@]"'.
1156
1157 -m Take the first argument as a pattern (should be quoted),
1158 and remove it from the argument list together with subse‐
1159 quent arguments that do not match this pattern.
1160
1161 -n Do not add a newline to the output.
1162
1163 -N Print the arguments separated and terminated by nulls.
1164 Again, print -rNC1 -- "$list[@]" is a canonical way to
1165 print an arbitrary list as null-delimited records.
1166
1167 -o Print the arguments sorted in ascending order.
1168
1169 -O Print the arguments sorted in descending order.
1170
1171 -p Print the arguments to the input of the coprocess.
1172
1173 -P Perform prompt expansion (see EXPANSION OF PROMPT
1174 SEQUENCES in zshmisc(1)). In combination with `-f',
1175 prompt escape sequences are parsed only within interpo‐
1176 lated arguments, not within the format string.
1177
1178 -r Ignore the escape conventions of echo.
1179
1180 -R Emulate the BSD echo command, which does not process
1181 escape sequences unless the -e flag is given. The -n
1182 flag suppresses the trailing newline. Only the -e and -n
1183 flags are recognized after -R; all other arguments and
1184 options are printed.
1185
1186 -s Place the results in the history list instead of on the
1187 standard output. Each argument to the print command is
1188 treated as a single word in the history, regardless of
1189 its content.
1190
1191 -S Place the results in the history list instead of on the
1192 standard output. In this case only a single argument is
1193 allowed; it will be split into words as if it were a full
1194 shell command line. The effect is similar to reading the
1195 line from a history file with the HIST_LEX_WORDS option
1196 active.
1197
1198 -u n Print the arguments to file descriptor n.
1199
1200 -v name
1201 Store the printed arguments as the value of the parameter
1202 name.
1203
1204 -x tab-stop
1205 Expand leading tabs on each line of output in the printed
1206 string assuming a tab stop every tab-stop characters.
1207 This is appropriate for formatting code that may be
1208 indented with tabs. Note that leading tabs of any argu‐
1209 ment to print, not just the first, are expanded, even if
1210 print is using spaces to separate arguments (the column
1211 count is maintained across arguments but may be incorrect
1212 on output owing to previous unexpanded tabs).
1213
1214 The start of the output of each print command is assumed
1215 to be aligned with a tab stop. Widths of multibyte char‐
1216 acters are handled if the option MULTIBYTE is in effect.
1217 This option is ignored if other formatting options are in
1218 effect, namely column alignment or printf style, or if
1219 output is to a special location such as shell history or
1220 the command line editor.
1221
1222 -X tab-stop
1223 This is similar to -x, except that all tabs in the
1224 printed string are expanded. This is appropriate if tabs
1225 in the arguments are being used to produce a table for‐
1226 mat.
1227
1228 -z Push the arguments onto the editing buffer stack, sepa‐
1229 rated by spaces.
1230
1231 If any of `-m', `-o' or `-O' are used in combination with `-f'
1232 and there are no arguments (after the removal process in the
1233 case of `-m') then nothing is printed.
1234
1235 printf [ -v name ] format [ arg ... ]
1236 Print the arguments according to the format specification. For‐
1237 matting rules are the same as used in C. The same escape
1238 sequences as for echo are recognised in the format. All C con‐
1239 version specifications ending in one of csdiouxXeEfgGn are han‐
1240 dled. In addition to this, `%b' can be used instead of `%s' to
1241 cause escape sequences in the argument to be recognised and `%q'
1242 can be used to quote the argument in such a way that allows it
1243 to be reused as shell input. With the numeric format specifiers,
1244 if the corresponding argument starts with a quote character, the
1245 numeric value of the following character is used as the number
1246 to print; otherwise the argument is evaluated as an arithmetic
1247 expression. See the section `Arithmetic Evaluation' in zsh‐
1248 misc(1) for a description of arithmetic expressions. With `%n',
1249 the corresponding argument is taken as an identifier which is
1250 created as an integer parameter.
1251
1252 Normally, conversion specifications are applied to each argument
1253 in order but they can explicitly specify the nth argument is to
1254 be used by replacing `%' by `%n$' and `*' by `*n$'. It is rec‐
1255 ommended that you do not mix references of this explicit style
1256 with the normal style and the handling of such mixed styles may
1257 be subject to future change.
1258
1259 If arguments remain unused after formatting, the format string
1260 is reused until all arguments have been consumed. With the print
1261 builtin, this can be suppressed by using the -r option. If more
1262 arguments are required by the format than have been specified,
1263 the behaviour is as if zero or an empty string had been speci‐
1264 fied as the argument.
1265
1266 The -v option causes the output to be stored as the value of the
1267 parameter name, instead of printed. If name is an array and the
1268 format string is reused when consuming arguments then one array
1269 element will be used for each use of the format string.
1270
1271 pushd [ -qsLP ] [ arg ]
1272 pushd [ -qsLP ] old new
1273 pushd [ -qsLP ] {+|-}n
1274 Change the current directory, and push the old current directory
1275 onto the directory stack. In the first form, change the current
1276 directory to arg. If arg is not specified, change to the second
1277 directory on the stack (that is, exchange the top two entries),
1278 or change to $HOME if the PUSHD_TO_HOME option is set or if
1279 there is only one entry on the stack. Otherwise, arg is inter‐
1280 preted as it would be by cd. The meaning of old and new in the
1281 second form is also the same as for cd.
1282
1283 The third form of pushd changes directory by rotating the direc‐
1284 tory list. An argument of the form `+n' identifies a stack
1285 entry by counting from the left of the list shown by the dirs
1286 command, starting with zero. An argument of the form `-n'
1287 counts from the right. If the PUSHD_MINUS option is set, the
1288 meanings of `+' and `-' in this context are swapped.
1289
1290 If the -q (quiet) option is specified, the hook function chpwd
1291 and the functions in the array $chpwd_functions are not called,
1292 and the new directory stack is not printed. This is useful for
1293 calls to pushd that do not change the environment seen by an
1294 interactive user.
1295
1296 If the option -q is not specified and the shell option
1297 PUSHD_SILENT is not set, the directory stack will be printed
1298 after a pushd is performed.
1299
1300 The options -s, -L and -P have the same meanings as for the cd
1301 builtin.
1302
1303 pushln [ arg ... ]
1304 Equivalent to print -nz.
1305
1306 pwd [ -rLP ]
1307 Print the absolute pathname of the current working directory.
1308 If the -r or the -P flag is specified, or the CHASE_LINKS option
1309 is set and the -L flag is not given, the printed path will not
1310 contain symbolic links.
1311
1312 r Same as fc -e -.
1313
1314
1315 read [ -rszpqAclneE ] [ -t [ num ] ] [ -k [ num ] ] [ -d delim ]
1316 [ -u n ] [ name[?prompt] ] [ name ... ]
1317 Read one line and break it into fields using the characters in
1318 $IFS as separators, except as noted below. The first field is
1319 assigned to the first name, the second field to the second name,
1320 etc., with leftover fields assigned to the last name. If name
1321 is omitted then REPLY is used for scalars and reply for arrays.
1322
1323 -r Raw mode: a `\' at the end of a line does not signify
1324 line continuation and backslashes in the line don't quote
1325 the following character and are not removed.
1326
1327 -s Don't echo back characters if reading from the terminal.
1328
1329 -q Read only one character from the terminal and set name to
1330 `y' if this character was `y' or `Y' and to `n' other‐
1331 wise. With this flag set the return status is zero only
1332 if the character was `y' or `Y'. This option may be used
1333 with a timeout (see -t); if the read times out, or
1334 encounters end of file, status 2 is returned. Input is
1335 read from the terminal unless one of -u or -p is present.
1336 This option may also be used within zle widgets.
1337
1338 -k [ num ]
1339 Read only one (or num) characters. All are assigned to
1340 the first name, without word splitting. This flag is
1341 ignored when -q is present. Input is read from the ter‐
1342 minal unless one of -u or -p is present. This option may
1343 also be used within zle widgets.
1344
1345 Note that despite the mnemonic `key' this option does
1346 read full characters, which may consist of multiple bytes
1347 if the option MULTIBYTE is set.
1348
1349 -z Read one entry from the editor buffer stack and assign it
1350 to the first name, without word splitting. Text is
1351 pushed onto the stack with `print -z' or with push-line
1352 from the line editor (see zshzle(1)). This flag is
1353 ignored when the -k or -q flags are present.
1354
1355 -e
1356 -E The input read is printed (echoed) to the standard out‐
1357 put. If the -e flag is used, no input is assigned to the
1358 parameters.
1359
1360 -A The first name is taken as the name of an array and all
1361 words are assigned to it.
1362
1363 -c
1364 -l These flags are allowed only if called inside a function
1365 used for completion (specified with the -K flag to com‐
1366 pctl). If the -c flag is given, the words of the current
1367 command are read. If the -l flag is given, the whole line
1368 is assigned as a scalar. If both flags are present, -l
1369 is used and -c is ignored.
1370
1371 -n Together with -c, the number of the word the cursor is on
1372 is read. With -l, the index of the character the cursor
1373 is on is read. Note that the command name is word number
1374 1, not word 0, and that when the cursor is at the end of
1375 the line, its character index is the length of the line
1376 plus one.
1377
1378 -u n Input is read from file descriptor n.
1379
1380 -p Input is read from the coprocess.
1381
1382 -d delim
1383 Input is terminated by the first character of delim
1384 instead of by newline.
1385
1386 -t [ num ]
1387 Test if input is available before attempting to read. If
1388 num is present, it must begin with a digit and will be
1389 evaluated to give a number of seconds, which may be a
1390 floating point number; in this case the read times out if
1391 input is not available within this time. If num is not
1392 present, it is taken to be zero, so that read returns
1393 immediately if no input is available. If no input is
1394 available, return status 1 and do not set any variables.
1395
1396 This option is not available when reading from the editor
1397 buffer with -z, when called from within completion with
1398 -c or -l, with -q which clears the input queue before
1399 reading, or within zle where other mechanisms should be
1400 used to test for input.
1401
1402 Note that read does not attempt to alter the input pro‐
1403 cessing mode. The default mode is canonical input, in
1404 which an entire line is read at a time, so usually `read
1405 -t' will not read anything until an entire line has been
1406 typed. However, when reading from the terminal with -k
1407 input is processed one key at a time; in this case, only
1408 availability of the first character is tested, so that
1409 e.g. `read -t -k 2' can still block on the second charac‐
1410 ter. Use two instances of `read -t -k' if this is not
1411 what is wanted.
1412
1413 If the first argument contains a `?', the remainder of this word
1414 is used as a prompt on standard error when the shell is interac‐
1415 tive.
1416
1417 The value (exit status) of read is 1 when an end-of-file is
1418 encountered, or when -c or -l is present and the command is not
1419 called from a compctl function, or as described for -q. Other‐
1420 wise the value is 0.
1421
1422 The behavior of some combinations of the -k, -p, -q, -u and -z
1423 flags is undefined. Presently -q cancels all the others, -p
1424 cancels -u, -k cancels -z, and otherwise -z cancels both -p and
1425 -u.
1426
1427 The -c or -l flags cancel any and all of -kpquz.
1428
1429 readonly
1430 Same as typeset -r. With the POSIX_BUILTINS option set, same as
1431 typeset -gr.
1432
1433 rehash Same as hash -r.
1434
1435 return [ n ]
1436 Causes a shell function or `.' script to return to the invoking
1437 script with the return status specified by an arithmetic expres‐
1438 sion n. If n is omitted, the return status is that of the last
1439 command executed.
1440
1441 If return was executed from a trap in a TRAPNAL function, the
1442 effect is different for zero and non-zero return status. With
1443 zero status (or after an implicit return at the end of the
1444 trap), the shell will return to whatever it was previously pro‐
1445 cessing; with a non-zero status, the shell will behave as inter‐
1446 rupted except that the return status of the trap is retained.
1447 Note that the numeric value of the signal which caused the trap
1448 is passed as the first argument, so the statement `return
1449 $((128+$1))' will return the same status as if the signal had
1450 not been trapped.
1451
1452 sched See the section `The zsh/sched Module' in zshmodules(1).
1453
1454
1455 set [ {+|-}options | {+|-}o [ option_name ] ] ... [ {+|-}A [ name ] ]
1456 [ arg ... ]
1457 Set the options for the shell and/or set the positional parame‐
1458 ters, or declare and set an array. If the -s option is given,
1459 it causes the specified arguments to be sorted before assigning
1460 them to the positional parameters (or to the array name if -A is
1461 used). With +s sort arguments in descending order. For the
1462 meaning of the other flags, see zshoptions(1). Flags may be
1463 specified by name using the -o option. If no option name is sup‐
1464 plied with -o, the current option states are printed: see the
1465 description of setopt below for more information on the format.
1466 With +o they are printed in a form that can be used as input to
1467 the shell.
1468
1469 If the -A flag is specified, name is set to an array containing
1470 the given args; if no name is specified, all arrays are printed
1471 together with their values.
1472
1473 If +A is used and name is an array, the given arguments will
1474 replace the initial elements of that array; if no name is speci‐
1475 fied, all arrays are printed without their values.
1476
1477 The behaviour of arguments after -A name or +A name depends on
1478 whether the option KSH_ARRAYS is set. If it is not set, all
1479 arguments following name are treated as values for the array,
1480 regardless of their form. If the option is set, normal option
1481 processing continues at that point; only regular arguments are
1482 treated as values for the array. This means that
1483
1484 set -A array -x -- foo
1485
1486 sets array to `-x -- foo' if KSH_ARRAYS is not set, but sets the
1487 array to foo and turns on the option `-x' if it is set.
1488
1489 If the -A flag is not present, but there are arguments beyond
1490 the options, the positional parameters are set. If the option
1491 list (if any) is terminated by `--', and there are no further
1492 arguments, the positional parameters will be unset.
1493
1494 If no arguments and no `--' are given, then the names and values
1495 of all parameters are printed on the standard output. If the
1496 only argument is `+', the names of all parameters are printed.
1497
1498 For historical reasons, `set -' is treated as `set +xv' and `set
1499 - args' as `set +xv -- args' when in any other emulation mode
1500 than zsh's native mode.
1501
1502 setcap See the section `The zsh/cap Module' in zshmodules(1).
1503
1504 setopt [ {+|-}options | {+|-}o option_name ] [ -m ] [ name ... ]
1505 Set the options for the shell. All options specified either
1506 with flags or by name are set.
1507
1508 If no arguments are supplied, the names of all options currently
1509 set are printed. The form is chosen so as to minimize the dif‐
1510 ferences from the default options for the current emulation (the
1511 default emulation being native zsh, shown as <Z> in zshop‐
1512 tions(1)). Options that are on by default for the emulation are
1513 shown with the prefix no only if they are off, while other
1514 options are shown without the prefix no and only if they are on.
1515 In addition to options changed from the default state by the
1516 user, any options activated automatically by the shell (for
1517 example, SHIN_STDIN or INTERACTIVE) will be shown in the list.
1518 The format is further modified by the option KSH_OPTION_PRINT,
1519 however the rationale for choosing options with or without the
1520 no prefix remains the same in this case.
1521
1522 If the -m flag is given the arguments are taken as patterns
1523 (which should be quoted to protect them from filename expan‐
1524 sion), and all options with names matching these patterns are
1525 set.
1526
1527 Note that a bad option name does not cause execution of subse‐
1528 quent shell code to be aborted; this is behaviour is different
1529 from that of `set -o'. This is because set is regarded as a
1530 special builtin by the POSIX standard, but setopt is not.
1531
1532 shift [ -p ] [ n ] [ name ... ]
1533 The positional parameters ${n+1} ... are renamed to $1 ...,
1534 where n is an arithmetic expression that defaults to 1. If any
1535 names are given then the arrays with these names are shifted
1536 instead of the positional parameters.
1537
1538 If the option -p is given arguments are instead removed (popped)
1539 from the end rather than the start of the array.
1540
1541 source file [ arg ... ]
1542 Same as `.', except that the current directory is always
1543 searched and is always searched first, before directories in
1544 $path.
1545
1546 stat See the section `The zsh/stat Module' in zshmodules(1).
1547
1548 suspend [ -f ]
1549 Suspend the execution of the shell (send it a SIGTSTP) until it
1550 receives a SIGCONT. Unless the -f option is given, this will
1551 refuse to suspend a login shell.
1552
1553 test [ arg ... ]
1554 [ [ arg ... ] ]
1555 Like the system version of test. Added for compatibility; use
1556 conditional expressions instead (see the section `Conditional
1557 Expressions'). The main differences between the conditional
1558 expression syntax and the test and [ builtins are: these com‐
1559 mands are not handled syntactically, so for example an empty
1560 variable expansion may cause an argument to be omitted; syntax
1561 errors cause status 2 to be returned instead of a shell error;
1562 and arithmetic operators expect integer arguments rather than
1563 arithmetic expressions.
1564
1565 The command attempts to implement POSIX and its extensions where
1566 these are specified. Unfortunately there are intrinsic ambigui‐
1567 ties in the syntax; in particular there is no distinction
1568 between test operators and strings that resemble them. The
1569 standard attempts to resolve these for small numbers of argu‐
1570 ments (up to four); for five or more arguments compatibility
1571 cannot be relied on. Users are urged wherever possible to use
1572 the `[[' test syntax which does not have these ambiguities.
1573
1574 times Print the accumulated user and system times for the shell and
1575 for processes run from the shell.
1576
1577 trap [ arg ] [ sig ... ]
1578 arg is a series of commands (usually quoted to protect it from
1579 immediate evaluation by the shell) to be read and executed when
1580 the shell receives any of the signals specified by one or more
1581 sig args. Each sig can be given as a number, or as the name of
1582 a signal either with or without the string SIG in front (e.g. 1,
1583 HUP, and SIGHUP are all the same signal).
1584
1585 If arg is `-', then the specified signals are reset to their
1586 defaults, or, if no sig args are present, all traps are reset.
1587
1588 If arg is an empty string, then the specified signals are
1589 ignored by the shell (and by the commands it invokes).
1590
1591 If arg is omitted but one or more sig args are provided (i.e.
1592 the first argument is a valid signal number or name), the effect
1593 is the same as if arg had been specified as `-'.
1594
1595 The trap command with no arguments prints a list of commands
1596 associated with each signal.
1597
1598 If sig is ZERR then arg will be executed after each command with
1599 a nonzero exit status. ERR is an alias for ZERR on systems that
1600 have no SIGERR signal (this is the usual case).
1601
1602 If sig is DEBUG then arg will be executed before each command if
1603 the option DEBUG_BEFORE_CMD is set (as it is by default), else
1604 after each command. Here, a `command' is what is described as a
1605 `sublist' in the shell grammar, see the section SIMPLE COMMANDS
1606 & PIPELINES in zshmisc(1). If DEBUG_BEFORE_CMD is set various
1607 additional features are available. First, it is possible to
1608 skip the next command by setting the option ERR_EXIT; see the
1609 description of the ERR_EXIT option in zshoptions(1). Also, the
1610 shell parameter ZSH_DEBUG_CMD is set to the string corresponding
1611 to the command to be executed following the trap. Note that
1612 this string is reconstructed from the internal format and may
1613 not be formatted the same way as the original text. The parame‐
1614 ter is unset after the trap is executed.
1615
1616 If sig is 0 or EXIT and the trap statement is executed inside
1617 the body of a function, then the command arg is executed after
1618 the function completes. The value of $? at the start of execu‐
1619 tion is the exit status of the shell or the return status of the
1620 function exiting. If sig is 0 or EXIT and the trap statement is
1621 not executed inside the body of a function, then the command arg
1622 is executed when the shell terminates; the trap runs before any
1623 zshexit hook functions.
1624
1625 ZERR, DEBUG, and EXIT traps are not executed inside other traps.
1626 ZERR and DEBUG traps are kept within subshells, while other
1627 traps are reset.
1628
1629 Note that traps defined with the trap builtin are slightly dif‐
1630 ferent from those defined as `TRAPNAL () { ... }', as the latter
1631 have their own function environment (line numbers, local vari‐
1632 ables, etc.) while the former use the environment of the command
1633 in which they were called. For example,
1634
1635 trap 'print $LINENO' DEBUG
1636
1637 will print the line number of a command executed after it has
1638 run, while
1639
1640 TRAPDEBUG() { print $LINENO; }
1641
1642 will always print the number zero.
1643
1644 Alternative signal names are allowed as described under kill
1645 above. Defining a trap under either name causes any trap under
1646 an alternative name to be removed. However, it is recommended
1647 that for consistency users stick exclusively to one name or
1648 another.
1649
1650 true [ arg ... ]
1651 Do nothing and return an exit status of 0.
1652
1653 ttyctl [ -fu ]
1654 The -f option freezes the tty (i.e. terminal or terminal emula‐
1655 tor), and -u unfreezes it. When the tty is frozen, no changes
1656 made to the tty settings by external programs will be honored by
1657 the shell, except for changes in the size of the screen; the
1658 shell will simply reset the settings to their previous values as
1659 soon as each command exits or is suspended. Thus, stty and sim‐
1660 ilar programs have no effect when the tty is frozen. Freezing
1661 the tty does not cause the current state to be remembered:
1662 instead, it causes future changes to the state to be blocked.
1663
1664 Without options it reports whether the terminal is frozen or
1665 not.
1666
1667 Note that, regardless of whether the tty is frozen or not, the
1668 shell needs to change the settings when the line editor starts,
1669 so unfreezing the tty does not guarantee settings made on the
1670 command line are preserved. Strings of commands run between
1671 editing the command line will see a consistent tty state. See
1672 also the shell variable STTY for a means of initialising the tty
1673 before running external commands.
1674
1675 type [ -wfpamsS ] name ...
1676 Equivalent to whence -v.
1677
1678
1679 typeset [ {+|-}AHUaghlmrtux ] [ {+|-}EFLRZip [ n ] ]
1680 [ + ] [ name[=value] ... ]
1681 typeset -T [ {+|-}Uglrux ] [ {+|-}LRZp [ n ] ]
1682 [ + | SCALAR[=value] array[=(value ...)] [ sep ] ]
1683 typeset -f [ {+|-}TUkmtuz ] [ + ] [ name ... ]
1684 Set or display attributes and values for shell parameters.
1685
1686 Except as noted below for control flags that change the behav‐
1687 ior, a parameter is created for each name that does not already
1688 refer to one. When inside a function, a new parameter is cre‐
1689 ated for every name (even those that already exist), and is
1690 unset again when the function completes. See `Local Parameters'
1691 in zshparam(1). The same rules apply to special shell parame‐
1692 ters, which retain their special attributes when made local.
1693
1694 For each name=value assignment, the parameter name is set to
1695 value.
1696
1697 If the shell option TYPESET_SILENT is not set, for each remain‐
1698 ing name that refers to a parameter that is already set, the
1699 name and value of the parameter are printed in the form of an
1700 assignment. Nothing is printed for newly-created parameters, or
1701 when any attribute flags listed below are given along with the
1702 name. Using `+' instead of minus to introduce an attribute
1703 turns it off.
1704
1705 If no name is present, the names and values of all parameters
1706 are printed. In this case the attribute flags restrict the dis‐
1707 play to only those parameters that have the specified
1708 attributes, and using `+' rather than `-' to introduce the flag
1709 suppresses printing of the values of parameters when there is no
1710 parameter name.
1711
1712 All forms of the command handle scalar assignment. Array
1713 assignment is possible if any of the reserved words declare,
1714 export, float, integer, local, readonly or typeset is matched
1715 when the line is parsed (N.B. not when it is executed). In this
1716 case the arguments are parsed as assignments, except that the
1717 `+=' syntax and the GLOB_ASSIGN option are not supported, and
1718 scalar values after = are not split further into words, even if
1719 expanded (regardless of the setting of the KSH_TYPESET option;
1720 this option is obsolete).
1721
1722 Examples of the differences between command and reserved word
1723 parsing:
1724
1725 # Reserved word parsing
1726 typeset svar=$(echo one word) avar=(several words)
1727
1728 The above creates a scalar parameter svar and an array parameter
1729 avar as if the assignments had been
1730
1731 svar="one word"
1732 avar=(several words)
1733
1734 On the other hand:
1735
1736 # Normal builtin interface
1737 builtin typeset svar=$(echo two words)
1738
1739 The builtin keyword causes the above to use the standard builtin
1740 interface to typeset in which argument parsing is performed in
1741 the same way as for other commands. This example creates a
1742 scalar svar containing the value two and another scalar parame‐
1743 ter words with no value. An array value in this case would
1744 either cause an error or be treated as an obscure set of glob
1745 qualifiers.
1746
1747 Arbitrary arguments are allowed if they take the form of assign‐
1748 ments after command line expansion; however, these only perform
1749 scalar assignment:
1750
1751 var='svar=val'
1752 typeset $var
1753
1754 The above sets the scalar parameter svar to the value val.
1755 Parentheses around the value within var would not cause array
1756 assignment as they will be treated as ordinary characters when
1757 $var is substituted. Any non-trivial expansion in the name part
1758 of the assignment causes the argument to be treated in this
1759 fashion:
1760
1761 typeset {var1,var2,var3}=name
1762
1763 The above syntax is valid, and has the expected effect of set‐
1764 ting the three parameters to the same value, but the command
1765 line is parsed as a set of three normal command line arguments
1766 to typeset after expansion. Hence it is not possible to assign
1767 to multiple arrays by this means.
1768
1769 Note that each interface to any of the commands my be disabled
1770 separately. For example, `disable -r typeset' disables the
1771 reserved word interface to typeset, exposing the builtin inter‐
1772 face, while `disable typeset' disables the builtin. Note that
1773 disabling the reserved word interface for typeset may cause
1774 problems with the output of `typeset -p', which assumes the
1775 reserved word interface is available in order to restore array
1776 and associative array values.
1777
1778 Unlike parameter assignment statements, typeset's exit status on
1779 an assignment that involves a command substitution does not
1780 reflect the exit status of the command substitution. Therefore,
1781 to test for an error in a command substitution, separate the
1782 declaration of the parameter from its initialization:
1783
1784 # WRONG
1785 typeset var1=$(exit 1) || echo "Trouble with var1"
1786
1787 # RIGHT
1788 typeset var1 && var1=$(exit 1) || echo "Trouble with var1"
1789
1790 To initialize a parameter param to a command output and mark it
1791 readonly, use typeset -r param or readonly param after the
1792 parameter assignment statement.
1793
1794 If no attribute flags are given, and either no name arguments
1795 are present or the flag +m is used, then each parameter name
1796 printed is preceded by a list of the attributes of that parame‐
1797 ter (array, association, exported, float, integer, readonly, or
1798 undefined for autoloaded parameters not yet loaded). If +m is
1799 used with attribute flags, and all those flags are introduced
1800 with +, the matching parameter names are printed but their val‐
1801 ues are not.
1802
1803 The following control flags change the behavior of typeset:
1804
1805 + If `+' appears by itself in a separate word as the last
1806 option, then the names of all parameters (functions with
1807 -f) are printed, but the values (function bodies) are
1808 not. No name arguments may appear, and it is an error
1809 for any other options to follow `+'. The effect of `+'
1810 is as if all attribute flags which precede it were given
1811 with a `+' prefix. For example, `typeset -U +' is equiv‐
1812 alent to `typeset +U' and displays the names of all
1813 arrays having the uniqueness attribute, whereas `typeset
1814 -f -U +' displays the names of all autoloadable func‐
1815 tions. If + is the only option, then type information
1816 (array, readonly, etc.) is also printed for each parame‐
1817 ter, in the same manner as `typeset +m "*"'.
1818
1819 -g The -g (global) means that any resulting parameter will
1820 not be restricted to local scope. Note that this does
1821 not necessarily mean that the parameter will be global,
1822 as the flag will apply to any existing parameter (even if
1823 unset) from an enclosing function. This flag does not
1824 affect the parameter after creation, hence it has no
1825 effect when listing existing parameters, nor does the
1826 flag +g have any effect except in combination with -m
1827 (see below).
1828
1829 -m If the -m flag is given the name arguments are taken as
1830 patterns (use quoting to prevent these from being inter‐
1831 preted as file patterns). With no attribute flags, all
1832 parameters (or functions with the -f flag) with matching
1833 names are printed (the shell option TYPESET_SILENT is not
1834 used in this case).
1835
1836 If the +g flag is combined with -m, a new local parameter
1837 is created for every matching parameter that is not
1838 already local. Otherwise -m applies all other flags or
1839 assignments to the existing parameters.
1840
1841 Except when assignments are made with name=value, using
1842 +m forces the matching parameters and their attributes to
1843 be printed, even inside a function. Note that -m is
1844 ignored if no patterns are given, so `typeset -m' dis‐
1845 plays attributes but `typeset -a +m' does not.
1846
1847 -p [ n ]
1848 If the -p option is given, parameters and values are
1849 printed in the form of a typeset command with an assign‐
1850 ment, regardless of other flags and options. Note that
1851 the -H flag on parameters is respected; no value will be
1852 shown for these parameters.
1853
1854 -p may be followed by an optional integer argument. Cur‐
1855 rently only the value 1 is supported. In this case
1856 arrays and associative arrays are printed with newlines
1857 between indented elements for readability.
1858
1859 -T [ scalar[=value] array[=(value ...)] [ sep ] ]
1860 This flag has a different meaning when used with -f; see
1861 below. Otherwise the -T option requires zero, two, or
1862 three arguments to be present. With no arguments, the
1863 list of parameters created in this fashion is shown.
1864 With two or three arguments, the first two are the name
1865 of a scalar and of an array parameter (in that order)
1866 that will be tied together in the manner of $PATH and
1867 $path. The optional third argument is a single-character
1868 separator which will be used to join the elements of the
1869 array to form the scalar; if absent, a colon is used, as
1870 with $PATH. Only the first character of the separator is
1871 significant; any remaining characters are ignored.
1872 Multibyte characters are not yet supported.
1873
1874 Only one of the scalar and array parameters may be
1875 assigned an initial value (the restrictions on assignment
1876 forms described above also apply).
1877
1878 Both the scalar and the array may be manipulated as nor‐
1879 mal. If one is unset, the other will automatically be
1880 unset too. There is no way of untying the variables
1881 without unsetting them, nor of converting the type of one
1882 of them with another typeset command; +T does not work,
1883 assigning an array to scalar is an error, and assigning a
1884 scalar to array sets it to be a single-element array.
1885
1886 Note that both `typeset -xT ...' and `export -T ...'
1887 work, but only the scalar will be marked for export.
1888 Setting the value using the scalar version causes a split
1889 on all separators (which cannot be quoted). It is possi‐
1890 ble to apply -T to two previously tied variables but with
1891 a different separator character, in which case the vari‐
1892 ables remain joined as before but the separator is
1893 changed.
1894
1895 When an existing scalar is tied to a new array, the value
1896 of the scalar is preserved but no attribute other than
1897 export will be preserved.
1898
1899 Attribute flags that transform the final value (-L, -R, -Z, -l,
1900 -u) are only applied to the expanded value at the point of a
1901 parameter expansion expression using `$'. They are not applied
1902 when a parameter is retrieved internally by the shell for any
1903 purpose.
1904
1905 The following attribute flags may be specified:
1906
1907 -A The names refer to associative array parameters; see
1908 `Array Parameters' in zshparam(1).
1909
1910 -L [ n ]
1911 Left justify and remove leading blanks from the value
1912 when the parameter is expanded. If n is nonzero, it
1913 defines the width of the field. If n is zero, the width
1914 is determined by the width of the value of the first
1915 assignment. In the case of numeric parameters, the
1916 length of the complete value assigned to the parameter is
1917 used to determine the width, not the value that would be
1918 output.
1919
1920 The width is the count of characters, which may be multi‐
1921 byte characters if the MULTIBYTE option is in effect.
1922 Note that the screen width of the character is not taken
1923 into account; if this is required, use padding with
1924 parameter expansion flags ${(ml...)...} as described in
1925 `Parameter Expansion Flags' in zshexpn(1).
1926
1927 When the parameter is expanded, it is filled on the right
1928 with blanks or truncated if necessary to fit the field.
1929 Note truncation can lead to unexpected results with
1930 numeric parameters. Leading zeros are removed if the -Z
1931 flag is also set.
1932
1933 -R [ n ]
1934 Similar to -L, except that right justification is used;
1935 when the parameter is expanded, the field is left filled
1936 with blanks or truncated from the end. May not be com‐
1937 bined with the -Z flag.
1938
1939 -U For arrays (but not for associative arrays), keep only
1940 the first occurrence of each duplicated value. This may
1941 also be set for tied parameters (see -T) or colon-sepa‐
1942 rated special parameters like PATH or FIGNORE, etc. Note
1943 the flag takes effect on assignment, and the type of the
1944 variable being assigned to is determinative; for vari‐
1945 ables with shared values it is therefore recommended to
1946 set the flag for all interfaces, e.g. `typeset -U PATH
1947 path'.
1948
1949 This flag has a different meaning when used with -f; see
1950 below.
1951
1952 -Z [ n ]
1953 Specially handled if set along with the -L flag. Other‐
1954 wise, similar to -R, except that leading zeros are used
1955 for padding instead of blanks if the first non-blank
1956 character is a digit. Numeric parameters are specially
1957 handled: they are always eligible for padding with
1958 zeroes, and the zeroes are inserted at an appropriate
1959 place in the output.
1960
1961 -a The names refer to array parameters. An array parameter
1962 may be created this way, but it may be assigned to in the
1963 typeset statement only if the reserved word form of type‐
1964 set is enabled (as it is by default). When displaying,
1965 both normal and associative arrays are shown.
1966
1967 -f The names refer to functions rather than parameters. No
1968 assignments can be made, and the only other valid flags
1969 are -t, -T, -k, -u, -U and -z. The flag -t turns on exe‐
1970 cution tracing for this function; the flag -T does the
1971 same, but turns off tracing for any named (not anonymous)
1972 function called from the present one, unless that func‐
1973 tion also has the -t or -T flag. The -u and -U flags
1974 cause the function to be marked for autoloading; -U also
1975 causes alias expansion to be suppressed when the function
1976 is loaded. See the description of the `autoload' builtin
1977 for details.
1978
1979 Note that the builtin functions provides the same basic
1980 capabilities as typeset -f but gives access to a few
1981 extra options; autoload gives further additional options
1982 for the case typeset -fu and typeset -fU.
1983
1984 -h Hide: only useful for special parameters (those marked
1985 `<S>' in the table in zshparam(1)), and for local parame‐
1986 ters with the same name as a special parameter, though
1987 harmless for others. A special parameter with this
1988 attribute will not retain its special effect when made
1989 local. Thus after `typeset -h PATH', a function contain‐
1990 ing `typeset PATH' will create an ordinary local parame‐
1991 ter without the usual behaviour of PATH. Alternatively,
1992 the local parameter may itself be given this attribute;
1993 hence inside a function `typeset -h PATH' creates an
1994 ordinary local parameter and the special PATH parameter
1995 is not altered in any way. It is also possible to create
1996 a local parameter using `typeset +h special', where the
1997 local copy of special will retain its special properties
1998 regardless of having the -h attribute. Global special
1999 parameters loaded from shell modules (currently those in
2000 zsh/mapfile and zsh/parameter) are automatically given
2001 the -h attribute to avoid name clashes.
2002
2003 -H Hide value: specifies that typeset will not display the
2004 value of the parameter when listing parameters; the dis‐
2005 play for such parameters is always as if the `+' flag had
2006 been given. Use of the parameter is in other respects
2007 normal, and the option does not apply if the parameter is
2008 specified by name, or by pattern with the -m option.
2009 This is on by default for the parameters in the
2010 zsh/parameter and zsh/mapfile modules. Note, however,
2011 that unlike the -h flag this is also useful for non-spe‐
2012 cial parameters.
2013
2014 -i [ n ]
2015 Use an internal integer representation. If n is nonzero
2016 it defines the output arithmetic base, otherwise it is
2017 determined by the first assignment. Bases from 2 to 36
2018 inclusive are allowed.
2019
2020 -E [ n ]
2021 Use an internal double-precision floating point represen‐
2022 tation. On output the variable will be converted to sci‐
2023 entific notation. If n is nonzero it defines the number
2024 of significant figures to display; the default is ten.
2025
2026 -F [ n ]
2027 Use an internal double-precision floating point represen‐
2028 tation. On output the variable will be converted to
2029 fixed-point decimal notation. If n is nonzero it defines
2030 the number of digits to display after the decimal point;
2031 the default is ten.
2032
2033 -l Convert the result to lower case whenever the parameter
2034 is expanded. The value is not converted when assigned.
2035
2036 -r The given names are marked readonly. Note that if name
2037 is a special parameter, the readonly attribute can be
2038 turned on, but cannot then be turned off.
2039
2040 If the POSIX_BUILTINS option is set, the readonly
2041 attribute is more restrictive: unset variables can be
2042 marked readonly and cannot then be set; furthermore, the
2043 readonly attribute cannot be removed from any variable.
2044
2045 It is still possible to change other attributes of the
2046 variable though, some of which like -U or -Z would affect
2047 the value. More generally, the readonly attribute should
2048 not be relied on as a security mechanism.
2049
2050 Note that in zsh (like in pdksh but unlike most other
2051 shells) it is still possible to create a local variable
2052 of the same name as this is considered a different vari‐
2053 able (though this variable, too, can be marked readonly).
2054 Special variables that have been made readonly retain
2055 their value and readonly attribute when made local.
2056
2057 -t Tags the named parameters. Tags have no special meaning
2058 to the shell. This flag has a different meaning when
2059 used with -f; see above.
2060
2061 -u Convert the result to upper case whenever the parameter
2062 is expanded. The value is not converted when assigned.
2063 This flag has a different meaning when used with -f; see
2064 above.
2065
2066 -x Mark for automatic export to the environment of subse‐
2067 quently executed commands. If the option GLOBAL_EXPORT
2068 is set, this implies the option -g, unless +g is also
2069 explicitly given; in other words the parameter is not
2070 made local to the enclosing function. This is for com‐
2071 patibility with previous versions of zsh.
2072
2073 ulimit [ -HSa ] [ { -bcdfiklmnpqrsTtvwx | -N resource } [ limit ] ... ]
2074 Set or display resource limits of the shell and the processes
2075 started by the shell. The value of limit can be a number in the
2076 unit specified below or one of the values `unlimited', which
2077 removes the limit on the resource, or `hard', which uses the
2078 current value of the hard limit on the resource.
2079
2080 By default, only soft limits are manipulated. If the -H flag is
2081 given use hard limits instead of soft limits. If the -S flag is
2082 given together with the -H flag set both hard and soft limits.
2083
2084 If no options are used, the file size limit (-f) is assumed.
2085
2086 If limit is omitted the current value of the specified resources
2087 are printed. When more than one resource value is printed, the
2088 limit name and unit is printed before each value.
2089
2090 When looping over multiple resources, the shell will abort imme‐
2091 diately if it detects a badly formed argument. However, if it
2092 fails to set a limit for some other reason it will continue try‐
2093 ing to set the remaining limits.
2094
2095 Not all the following resources are supported on all systems.
2096 Running ulimit -a will show which are supported.
2097
2098 -a Lists all of the current resource limits.
2099 -b Socket buffer size in bytes (N.B. not kilobytes)
2100 -c 512-byte blocks on the size of core dumps.
2101 -d Kilobytes on the size of the data segment.
2102 -f 512-byte blocks on the size of files written.
2103 -i The number of pending signals.
2104 -k The number of kqueues allocated.
2105 -l Kilobytes on the size of locked-in memory.
2106 -m Kilobytes on the size of physical memory.
2107 -n open file descriptors.
2108 -p The number of pseudo-terminals.
2109 -q Bytes in POSIX message queues.
2110 -r Maximum real time priority. On some systems where this
2111 is not available, such as NetBSD, this has the same
2112 effect as -T for compatibility with sh.
2113 -s Kilobytes on the size of the stack.
2114 -T The number of simultaneous threads available to the user.
2115 -t CPU seconds to be used.
2116 -u The number of processes available to the user.
2117 -v Kilobytes on the size of virtual memory. On some systems
2118 this refers to the limit called `address space'.
2119 -w Kilobytes on the size of swapped out memory.
2120 -x The number of locks on files.
2121
2122 A resource may also be specified by integer in the form `-N
2123 resource', where resource corresponds to the integer defined for
2124 the resource by the operating system. This may be used to set
2125 the limits for resources known to the shell which do not corre‐
2126 spond to option letters. Such limits will be shown by number in
2127 the output of `ulimit -a'.
2128
2129 The number may alternatively be out of the range of limits com‐
2130 piled into the shell. The shell will try to read or write the
2131 limit anyway, and will report an error if this fails.
2132
2133 umask [ -S ] [ mask ]
2134 The umask is set to mask. mask can be either an octal number or
2135 a symbolic value as described in chmod(1). If mask is omitted,
2136 the current value is printed. The -S option causes the mask to
2137 be printed as a symbolic value. Otherwise, the mask is printed
2138 as an octal number. Note that in the symbolic form the permis‐
2139 sions you specify are those which are to be allowed (not denied)
2140 to the users specified.
2141
2142 unalias [ -ams ] name ...
2143 Removes aliases. This command works the same as unhash -a,
2144 except that the -a option removes all regular or global aliases,
2145 or with -s all suffix aliases: in this case no name arguments
2146 may appear. The options -m (remove by pattern) and -s without
2147 -a (remove listed suffix aliases) behave as for unhash -a. Note
2148 that the meaning of -a is different between unalias and unhash.
2149
2150 unfunction
2151 Same as unhash -f.
2152
2153 unhash [ -adfms ] name ...
2154 Remove the element named name from an internal hash table. The
2155 default is remove elements from the command hash table. The -a
2156 option causes unhash to remove regular or global aliases; note
2157 when removing a global aliases that the argument must be quoted
2158 to prevent it from being expanded before being passed to the
2159 command. The -s option causes unhash to remove suffix aliases.
2160 The -f option causes unhash to remove shell functions. The -d
2161 options causes unhash to remove named directories. If the -m
2162 flag is given the arguments are taken as patterns (should be
2163 quoted) and all elements of the corresponding hash table with
2164 matching names will be removed.
2165
2166 unlimit [ -hs ] resource ...
2167 The resource limit for each resource is set to the hard limit.
2168 If the -h flag is given and the shell has appropriate privi‐
2169 leges, the hard resource limit for each resource is removed.
2170 The resources of the shell process are only changed if the -s
2171 flag is given.
2172
2173 The unlimit command is not made available by default when the
2174 shell starts in a mode emulating another shell. It can be made
2175 available with the command `zmodload -F zsh/rlimits b:unlimit'.
2176
2177 unset [ -fmv ] name ...
2178 Each named parameter is unset. Local parameters remain local
2179 even if unset; they appear unset within scope, but the previous
2180 value will still reappear when the scope ends.
2181
2182 Individual elements of associative array parameters may be unset
2183 by using subscript syntax on name, which should be quoted (or
2184 the entire command prefixed with noglob) to protect the sub‐
2185 script from filename generation.
2186
2187 If the -m flag is specified the arguments are taken as patterns
2188 (should be quoted) and all parameters with matching names are
2189 unset. Note that this cannot be used when unsetting associative
2190 array elements, as the subscript will be treated as part of the
2191 pattern.
2192
2193 The -v flag specifies that name refers to parameters. This is
2194 the default behaviour.
2195
2196 unset -f is equivalent to unfunction.
2197
2198 unsetopt [ {+|-}options | {+|-}o option_name ] [ name ... ]
2199 Unset the options for the shell. All options specified either
2200 with flags or by name are unset. If no arguments are supplied,
2201 the names of all options currently unset are printed. If the -m
2202 flag is given the arguments are taken as patterns (which should
2203 be quoted to preserve them from being interpreted as glob pat‐
2204 terns), and all options with names matching these patterns are
2205 unset.
2206
2207 vared See the section `Zle Builtins' in zshzle(1).
2208
2209 wait [ job ... ]
2210 Wait for the specified jobs or processes. If job is not given
2211 then all currently active child processes are waited for. Each
2212 job can be either a job specification or the process ID of a job
2213 in the job table. The exit status from this command is that of
2214 the job waited for. If job represents an unknown job or process
2215 ID, a warning is printed (unless the POSIX_BUILTINS option is
2216 set) and the exit status is 127.
2217
2218 It is possible to wait for recent processes (specified by
2219 process ID, not by job) that were running in the background even
2220 if the process has exited. Typically the process ID will be
2221 recorded by capturing the value of the variable $! immediately
2222 after the process has been started. There is a limit on the
2223 number of process IDs remembered by the shell; this is given by
2224 the value of the system configuration parameter CHILD_MAX. When
2225 this limit is reached, older process IDs are discarded, least
2226 recently started processes first.
2227
2228 Note there is no protection against the process ID wrapping,
2229 i.e. if the wait is not executed soon enough there is a chance
2230 the process waited for is the wrong one. A conflict implies
2231 both process IDs have been generated by the shell, as other pro‐
2232 cesses are not recorded, and that the user is potentially inter‐
2233 ested in both, so this problem is intrinsic to process IDs.
2234
2235 whence [ -vcwfpamsS ] [ -x num ] name ...
2236 For each name, indicate how it would be interpreted if used as a
2237 command name.
2238
2239 If name is not an alias, built-in command, external command,
2240 shell function, hashed command, or a reserved word, the exit
2241 status shall be non-zero, and -- if -v, -c, or -w was passed --
2242 a message will be written to standard output. (This is differ‐
2243 ent from other shells that write that message to standard
2244 error.)
2245
2246 whence is most useful when name is only the last path component
2247 of a command, i.e. does not include a `/'; in particular, pat‐
2248 tern matching only succeeds if just the non-directory component
2249 of the command is passed.
2250
2251 -v Produce a more verbose report.
2252
2253 -c Print the results in a csh-like format. This takes
2254 precedence over -v.
2255
2256 -w For each name, print `name: word' where word is one of
2257 alias, builtin, command, function, hashed, reserved or
2258 none, according as name corresponds to an alias, a
2259 built-in command, an external command, a shell function,
2260 a command defined with the hash builtin, a reserved word,
2261 or is not recognised. This takes precedence over -v and
2262 -c.
2263
2264 -f Causes the contents of a shell function to be displayed,
2265 which would otherwise not happen unless the -c flag were
2266 used.
2267
2268 -p Do a path search for name even if it is an alias,
2269 reserved word, shell function or builtin.
2270
2271 -a Do a search for all occurrences of name throughout the
2272 command path. Normally only the first occurrence is
2273 printed.
2274
2275 -m The arguments are taken as patterns (pattern characters
2276 should be quoted), and the information is displayed for
2277 each command matching one of these patterns.
2278
2279 -s If a pathname contains symlinks, print the symlink-free
2280 pathname as well.
2281
2282 -S As -s, but if the pathname had to be resolved by follow‐
2283 ing multiple symlinks, the intermediate steps are
2284 printed, too. The symlink resolved at each step might be
2285 anywhere in the path.
2286
2287 -x num Expand tabs when outputting shell functions using the -c
2288 option. This has the same effect as the -x option to the
2289 functions builtin.
2290
2291 where [ -wpmsS ] [ -x num ] name ...
2292 Equivalent to whence -ca.
2293
2294 which [ -wpamsS ] [ -x num ] name ...
2295 Equivalent to whence -c.
2296
2297 zcompile [ -U ] [ -z | -k ] [ -R | -M ] file [ name ... ]
2298 zcompile -ca [ -m ] [ -R | -M ] file [ name ... ]
2299 zcompile -t file [ name ... ]
2300 This builtin command can be used to compile functions or
2301 scripts, storing the compiled form in a file, and to examine
2302 files containing the compiled form. This allows faster
2303 autoloading of functions and sourcing of scripts by avoiding
2304 parsing of the text when the files are read.
2305
2306 The first form (without the -c, -a or -t options) creates a com‐
2307 piled file. If only the file argument is given, the output file
2308 has the name `file.zwc' and will be placed in the same directory
2309 as the file. The shell will load the compiled file instead of
2310 the normal function file when the function is autoloaded; see
2311 the section `Autoloading Functions' in zshmisc(1) for a descrip‐
2312 tion of how autoloaded functions are searched. The extension
2313 .zwc stands for `zsh word code'.
2314
2315 If there is at least one name argument, all the named files are
2316 compiled into the output file given as the first argument. If
2317 file does not end in .zwc, this extension is automatically
2318 appended. Files containing multiple compiled functions are
2319 called `digest' files, and are intended to be used as elements
2320 of the FPATH/fpath special array.
2321
2322 The second form, with the -c or -a options, writes the compiled
2323 definitions for all the named functions into file. For -c, the
2324 names must be functions currently defined in the shell, not
2325 those marked for autoloading. Undefined functions that are
2326 marked for autoloading may be written by using the -a option, in
2327 which case the fpath is searched and the contents of the defini‐
2328 tion files for those functions, if found, are compiled into
2329 file. If both -c and -a are given, names of both defined func‐
2330 tions and functions marked for autoloading may be given. In
2331 either case, the functions in files written with the -c or -a
2332 option will be autoloaded as if the KSH_AUTOLOAD option were
2333 unset.
2334
2335 The reason for handling loaded and not-yet-loaded functions with
2336 different options is that some definition files for autoloading
2337 define multiple functions, including the function with the same
2338 name as the file, and, at the end, call that function. In such
2339 cases the output of `zcompile -c' does not include the addi‐
2340 tional functions defined in the file, and any other initializa‐
2341 tion code in the file is lost. Using `zcompile -a' captures all
2342 this extra information.
2343
2344 If the -m option is combined with -c or -a, the names are used
2345 as patterns and all functions whose names match one of these
2346 patterns will be written. If no name is given, the definitions
2347 of all functions currently defined or marked as autoloaded will
2348 be written.
2349
2350 Note the second form cannot be used for compiling functions that
2351 include redirections as part of the definition rather than
2352 within the body of the function; for example
2353
2354 fn1() { { ... } >~/logfile }
2355
2356 can be compiled but
2357
2358 fn1() { ... } >~/logfile
2359
2360 cannot. It is possible to use the first form of zcompile to
2361 compile autoloadable functions that include the full function
2362 definition instead of just the body of the function.
2363
2364 The third form, with the -t option, examines an existing com‐
2365 piled file. Without further arguments, the names of the origi‐
2366 nal files compiled into it are listed. The first line of output
2367 shows the version of the shell which compiled the file and how
2368 the file will be used (i.e. by reading it directly or by mapping
2369 it into memory). With arguments, nothing is output and the
2370 return status is set to zero if definitions for all names were
2371 found in the compiled file, and non-zero if the definition for
2372 at least one name was not found.
2373
2374 Other options:
2375
2376 -U Aliases are not expanded when compiling the named files.
2377
2378 -R When the compiled file is read, its contents are copied
2379 into the shell's memory, rather than memory-mapped (see
2380 -M). This happens automatically on systems that do not
2381 support memory mapping.
2382
2383 When compiling scripts instead of autoloadable functions,
2384 it is often desirable to use this option; otherwise the
2385 whole file, including the code to define functions which
2386 have already been defined, will remain mapped, conse‐
2387 quently wasting memory.
2388
2389 -M The compiled file is mapped into the shell's memory when
2390 read. This is done in such a way that multiple instances
2391 of the shell running on the same host will share this
2392 mapped file. If neither -R nor -M is given, the zcompile
2393 builtin decides what to do based on the size of the com‐
2394 piled file.
2395
2396 -k
2397 -z These options are used when the compiled file contains
2398 functions which are to be autoloaded. If -z is given, the
2399 function will be autoloaded as if the KSH_AUTOLOAD option
2400 is not set, even if it is set at the time the compiled
2401 file is read, while if the -k is given, the function will
2402 be loaded as if KSH_AUTOLOAD is set. These options also
2403 take precedence over any -k or -z options specified to
2404 the autoload builtin. If neither of these options is
2405 given, the function will be loaded as determined by the
2406 setting of the KSH_AUTOLOAD option at the time the com‐
2407 piled file is read.
2408
2409 These options may also appear as many times as necessary
2410 between the listed names to specify the loading style of
2411 all following functions, up to the next -k or -z.
2412
2413 The created file always contains two versions of the com‐
2414 piled format, one for big-endian machines and one for
2415 small-endian machines. The upshot of this is that the
2416 compiled file is machine independent and if it is read or
2417 mapped, only one half of the file is actually used (and
2418 mapped).
2419
2420 zformat
2421 See the section `The zsh/zutil Module' in zshmodules(1).
2422
2423 zftp See the section `The zsh/zftp Module' in zshmodules(1).
2424
2425 zle See the section `Zle Builtins' in zshzle(1).
2426
2427 zmodload [ -dL ] [ -s ] [ ... ]
2428 zmodload -F [ -alLme -P param ] module [ [+-]feature ... ]
2429 zmodload -e [ -A ] [ ... ]
2430 zmodload [ -a [ -bcpf [ -I ] ] ] [ -iL ] ...
2431 zmodload -u [ -abcdpf [ -I ] ] [ -iL ] ...
2432 zmodload -A [ -L ] [ modalias[=module] ... ]
2433 zmodload -R modalias ...
2434 Performs operations relating to zsh's loadable modules. Loading
2435 of modules while the shell is running (`dynamical loading') is
2436 not available on all operating systems, or on all installations
2437 on a particular operating system, although the zmodload command
2438 itself is always available and can be used to manipulate modules
2439 built into versions of the shell executable without dynamical
2440 loading.
2441
2442 Without arguments the names of all currently loaded binary mod‐
2443 ules are printed. The -L option causes this list to be in the
2444 form of a series of zmodload commands. Forms with arguments
2445 are:
2446
2447 zmodload [ -is ] name ...
2448 zmodload -u [ -i ] name ...
2449 In the simplest case, zmodload loads a binary module.
2450 The module must be in a file with a name consisting of
2451 the specified name followed by a standard suffix, usually
2452 `.so' (`.sl' on HPUX). If the module to be loaded is
2453 already loaded the duplicate module is ignored. If zmod‐
2454 load detects an inconsistency, such as an invalid module
2455 name or circular dependency list, the current code block
2456 is aborted. If it is available, the module is loaded if
2457 necessary, while if it is not available, non-zero status
2458 is silently returned. The option -i is accepted for com‐
2459 patibility but has no effect.
2460
2461 The named module is searched for in the same way a com‐
2462 mand is, using $module_path instead of $path. However,
2463 the path search is performed even when the module name
2464 contains a `/', which it usually does. There is no way
2465 to prevent the path search.
2466
2467 If the module supports features (see below), zmodload
2468 tries to enable all features when loading a module. If
2469 the module was successfully loaded but not all features
2470 could be enabled, zmodload returns status 2.
2471
2472 If the option -s is given, no error is printed if the
2473 module was not available (though other errors indicating
2474 a problem with the module are printed). The return sta‐
2475 tus indicates if the module was loaded. This is appro‐
2476 priate if the caller considers the module optional.
2477
2478 With -u, zmodload unloads modules. The same name must be
2479 given that was given when the module was loaded, but it
2480 is not necessary for the module to exist in the file sys‐
2481 tem. The -i option suppresses the error if the module is
2482 already unloaded (or was never loaded).
2483
2484 Each module has a boot and a cleanup function. The mod‐
2485 ule will not be loaded if its boot function fails. Simi‐
2486 larly a module can only be unloaded if its cleanup func‐
2487 tion runs successfully.
2488
2489 zmodload -F [ -almLe -P param ] module [ [+-]feature ... ]
2490 zmodload -F allows more selective control over the fea‐
2491 tures provided by modules. With no options apart from
2492 -F, the module named module is loaded, if it was not
2493 already loaded, and the list of features is set to the
2494 required state. If no features are specified, the module
2495 is loaded, if it was not already loaded, but the state of
2496 features is unchanged. Each feature may be preceded by a
2497 + to turn the feature on, or - to turn it off; the + is
2498 assumed if neither character is present. Any feature not
2499 explicitly mentioned is left in its current state; if the
2500 module was not previously loaded this means any such fea‐
2501 tures will remain disabled. The return status is zero if
2502 all features were set, 1 if the module failed to load,
2503 and 2 if some features could not be set (for example, a
2504 parameter couldn't be added because there was a different
2505 parameter of the same name) but the module was loaded.
2506
2507 The standard features are builtins, conditions, parame‐
2508 ters and math functions; these are indicated by the pre‐
2509 fix `b:', `c:' (`C:' for an infix condition), `p:' and
2510 `f:', respectively, followed by the name that the corre‐
2511 sponding feature would have in the shell. For example,
2512 `b:strftime' indicates a builtin named strftime and
2513 p:EPOCHSECONDS indicates a parameter named EPOCHSECONDS.
2514 The module may provide other (`abstract') features of its
2515 own as indicated by its documentation; these have no pre‐
2516 fix.
2517
2518 With -l or -L, features provided by the module are
2519 listed. With -l alone, a list of features together with
2520 their states is shown, one feature per line. With -L
2521 alone, a zmodload -F command that would cause enabled
2522 features of the module to be turned on is shown. With
2523 -lL, a zmodload -F command that would cause all the fea‐
2524 tures to be set to their current state is shown. If one
2525 of these combinations is given with the option -P param
2526 then the parameter param is set to an array of features,
2527 either features together with their state or (if -L alone
2528 is given) enabled features.
2529
2530 With the option -L the module name may be omitted; then a
2531 list of all enabled features for all modules providing
2532 features is printed in the form of zmodload -F commands.
2533 If -l is also given, the state of both enabled and dis‐
2534 abled features is output in that form.
2535
2536 A set of features may be provided together with -l or -L
2537 and a module name; in that case only the state of those
2538 features is considered. Each feature may be preceded by
2539 + or - but the character has no effect. If no set of
2540 features is provided, all features are considered.
2541
2542 With -e, the command first tests that the module is
2543 loaded; if it is not, status 1 is returned. If the mod‐
2544 ule is loaded, the list of features given as an argument
2545 is examined. Any feature given with no prefix is simply
2546 tested to see if the module provides it; any feature
2547 given with a prefix + or - is tested to see if is pro‐
2548 vided and in the given state. If the tests on all fea‐
2549 tures in the list succeed, status 0 is returned, else
2550 status 1.
2551
2552 With -m, each entry in the given list of features is
2553 taken as a pattern to be matched against the list of fea‐
2554 tures provided by the module. An initial + or - must be
2555 given explicitly. This may not be combined with the -a
2556 option as autoloads must be specified explicitly.
2557
2558 With -a, the given list of features is marked for
2559 autoload from the specified module, which may not yet be
2560 loaded. An optional + may appear before the feature
2561 name. If the feature is prefixed with -, any existing
2562 autoload is removed. The options -l and -L may be used
2563 to list autoloads. Autoloading is specific to individual
2564 features; when the module is loaded only the requested
2565 feature is enabled. Autoload requests are preserved if
2566 the module is subsequently unloaded until an explicit
2567 `zmodload -Fa module -feature' is issued. It is not an
2568 error to request an autoload for a feature of a module
2569 that is already loaded.
2570
2571 When the module is loaded each autoload is checked
2572 against the features actually provided by the module; if
2573 the feature is not provided the autoload request is
2574 deleted. A warning message is output; if the module is
2575 being loaded to provide a different feature, and that
2576 autoload is successful, there is no effect on the status
2577 of the current command. If the module is already loaded
2578 at the time when zmodload -Fa is run, an error message is
2579 printed and status 1 returned.
2580
2581 zmodload -Fa can be used with the -l, -L, -e and -P
2582 options for listing and testing the existence of
2583 autoloadable features. In this case -l is ignored if -L
2584 is specified. zmodload -FaL with no module name lists
2585 autoloads for all modules.
2586
2587 Note that only standard features as described above can
2588 be autoloaded; other features require the module to be
2589 loaded before enabling.
2590
2591 zmodload -d [ -L ] [ name ]
2592 zmodload -d name dep ...
2593 zmodload -ud name [ dep ... ]
2594 The -d option can be used to specify module dependencies.
2595 The modules named in the second and subsequent arguments
2596 will be loaded before the module named in the first argu‐
2597 ment.
2598
2599 With -d and one argument, all dependencies for that mod‐
2600 ule are listed. With -d and no arguments, all module
2601 dependencies are listed. This listing is by default in a
2602 Makefile-like format. The -L option changes this format
2603 to a list of zmodload -d commands.
2604
2605 If -d and -u are both used, dependencies are removed. If
2606 only one argument is given, all dependencies for that
2607 module are removed.
2608
2609 zmodload -ab [ -L ]
2610 zmodload -ab [ -i ] name [ builtin ... ]
2611 zmodload -ub [ -i ] builtin ...
2612 The -ab option defines autoloaded builtins. It defines
2613 the specified builtins. When any of those builtins is
2614 called, the module specified in the first argument is
2615 loaded and all its features are enabled (for selective
2616 control of features use `zmodload -F -a' as described
2617 above). If only the name is given, one builtin is
2618 defined, with the same name as the module. -i suppresses
2619 the error if the builtin is already defined or
2620 autoloaded, but not if another builtin of the same name
2621 is already defined.
2622
2623 With -ab and no arguments, all autoloaded builtins are
2624 listed, with the module name (if different) shown in
2625 parentheses after the builtin name. The -L option
2626 changes this format to a list of zmodload -a commands.
2627
2628 If -b is used together with the -u option, it removes
2629 builtins previously defined with -ab. This is only pos‐
2630 sible if the builtin is not yet loaded. -i suppresses
2631 the error if the builtin is already removed (or never
2632 existed).
2633
2634 Autoload requests are retained if the module is subse‐
2635 quently unloaded until an explicit `zmodload -ub builtin'
2636 is issued.
2637
2638 zmodload -ac [ -IL ]
2639 zmodload -ac [ -iI ] name [ cond ... ]
2640 zmodload -uc [ -iI ] cond ...
2641 The -ac option is used to define autoloaded condition
2642 codes. The cond strings give the names of the conditions
2643 defined by the module. The optional -I option is used to
2644 define infix condition names. Without this option prefix
2645 condition names are defined.
2646
2647 If given no condition names, all defined names are listed
2648 (as a series of zmodload commands if the -L option is
2649 given).
2650
2651 The -uc option removes definitions for autoloaded condi‐
2652 tions.
2653
2654 zmodload -ap [ -L ]
2655 zmodload -ap [ -i ] name [ parameter ... ]
2656 zmodload -up [ -i ] parameter ...
2657 The -p option is like the -b and -c options, but makes
2658 zmodload work on autoloaded parameters instead.
2659
2660 zmodload -af [ -L ]
2661 zmodload -af [ -i ] name [ function ... ]
2662 zmodload -uf [ -i ] function ...
2663 The -f option is like the -b, -p, and -c options, but
2664 makes zmodload work on autoloaded math functions instead.
2665
2666 zmodload -a [ -L ]
2667 zmodload -a [ -i ] name [ builtin ... ]
2668 zmodload -ua [ -i ] builtin ...
2669 Equivalent to -ab and -ub.
2670
2671 zmodload -e [ -A ] [ string ... ]
2672 The -e option without arguments lists all loaded modules;
2673 if the -A option is also given, module aliases corre‐
2674 sponding to loaded modules are also shown. If arguments
2675 are provided, nothing is printed; the return status is
2676 set to zero if all strings given as arguments are names
2677 of loaded modules and to one if at least on string is not
2678 the name of a loaded module. This can be used to test
2679 for the availability of things implemented by modules.
2680 In this case, any aliases are automatically resolved and
2681 the -A flag is not used.
2682
2683 zmodload -A [ -L ] [ modalias[=module] ... ]
2684 For each argument, if both modalias and module are given,
2685 define modalias to be an alias for the module module. If
2686 the module modalias is ever subsequently requested,
2687 either via a call to zmodload or implicitly, the shell
2688 will attempt to load module instead. If module is not
2689 given, show the definition of modalias. If no arguments
2690 are given, list all defined module aliases. When list‐
2691 ing, if the -L flag was also given, list the definition
2692 as a zmodload command to recreate the alias.
2693
2694 The existence of aliases for modules is completely inde‐
2695 pendent of whether the name resolved is actually loaded
2696 as a module: while the alias exists, loading and unload‐
2697 ing the module under any alias has exactly the same
2698 effect as using the resolved name, and does not affect
2699 the connection between the alias and the resolved name
2700 which can be removed either by zmodload -R or by redefin‐
2701 ing the alias. Chains of aliases (i.e. where the first
2702 resolved name is itself an alias) are valid so long as
2703 these are not circular. As the aliases take the same
2704 format as module names, they may include path separators:
2705 in this case, there is no requirement for any part of the
2706 path named to exist as the alias will be resolved first.
2707 For example, `any/old/alias' is always a valid alias.
2708
2709 Dependencies added to aliased modules are actually added
2710 to the resolved module; these remain if the alias is
2711 removed. It is valid to create an alias whose name is
2712 one of the standard shell modules and which resolves to a
2713 different module. However, if a module has dependencies,
2714 it will not be possible to use the module name as an
2715 alias as the module will already be marked as a loadable
2716 module in its own right.
2717
2718 Apart from the above, aliases can be used in the zmodload
2719 command anywhere module names are required. However,
2720 aliases will not be shown in lists of loaded modules with
2721 a bare `zmodload'.
2722
2723 zmodload -R modalias ...
2724 For each modalias argument that was previously defined as
2725 a module alias via zmodload -A, delete the alias. If any
2726 was not defined, an error is caused and the remainder of
2727 the line is ignored.
2728
2729 Note that zsh makes no distinction between modules that were
2730 linked into the shell and modules that are loaded dynamically.
2731 In both cases this builtin command has to be used to make avail‐
2732 able the builtins and other things defined by modules (unless
2733 the module is autoloaded on these definitions). This is true
2734 even for systems that don't support dynamic loading of modules.
2735
2736 zparseopts
2737 See the section `The zsh/zutil Module' in zshmodules(1).
2738
2739 zprof See the section `The zsh/zprof Module' in zshmodules(1).
2740
2741 zpty See the section `The zsh/zpty Module' in zshmodules(1).
2742
2743 zregexparse
2744 See the section `The zsh/zutil Module' in zshmodules(1).
2745
2746 zsocket
2747 See the section `The zsh/net/socket Module' in zshmodules(1).
2748
2749 zstyle See the section `The zsh/zutil Module' in zshmodules(1).
2750
2751 ztcp See the section `The zsh/net/tcp Module' in zshmodules(1).
2752
2753
2754
2755zsh 5.8 February 14, 2020 ZSHBUILTINS(1)