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