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