"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Doc/zsh.info-1" between
zsh-5.8.1-doc.tar.xz and zsh-5.9-doc.tar.xz

About: Zsh is a powerful UNIX command interpreter (shell). Documentation.

zsh.info-1  (zsh-5.8.1-doc.tar.xz):zsh.info-1  (zsh-5.9-doc.tar.xz)
skipping to change at line 20 skipping to change at line 20
The Z Shell Manual The Z Shell Manual
****************** ******************
This Info file documents Zsh, a freely available UNIX command This Info file documents Zsh, a freely available UNIX command
interpreter (shell), which of the standard shells most closely interpreter (shell), which of the standard shells most closely
resembles the Korn shell (ksh), although it is not completely resembles the Korn shell (ksh), although it is not completely
compatible. Zsh is able to emulate POSIX shells, but its default mode compatible. Zsh is able to emulate POSIX shells, but its default mode
is not POSIX compatible, either. is not POSIX compatible, either.
Version 5.8.1, last updated February 12, 2022. Version 5.9, last updated May 14, 2022.
* Menu: * Menu:
* The Z Shell Manual:: * The Z Shell Manual::
* Introduction:: * Introduction::
* Roadmap:: * Roadmap::
* Invocation:: * Invocation::
* Files:: * Files::
* Shell Grammar:: * Shell Grammar::
* Redirection:: * Redirection::
skipping to change at line 119 skipping to change at line 119
* Specifying Options:: * Specifying Options::
* Description of Options:: * Description of Options::
* Option Aliases:: * Option Aliases::
* Single Letter Options:: * Single Letter Options::
Zsh Line Editor Zsh Line Editor
* Keymaps:: * Keymaps::
* Zle Builtins:: * Zle Builtins::
* Zle Widgets:: * Zle Widgets::
* User-Defined Widgets::
* Standard Widgets::
* Character Highlighting:: * Character Highlighting::
Completion Widgets Completion Widgets
* Completion Special Parameters:: * Completion Special Parameters::
* Completion Builtin Commands:: * Completion Builtin Commands::
* Completion Condition Codes:: * Completion Condition Codes::
* Completion Matching Control:: * Completion Matching Control::
* Completion Widget Example:: * Completion Widget Example::
skipping to change at line 177 skipping to change at line 179
* The zsh/pcre Module:: * The zsh/pcre Module::
* The zsh/param/private Module:: * The zsh/param/private Module::
* The zsh/regex Module:: * The zsh/regex Module::
* The zsh/sched Module:: * The zsh/sched Module::
* The zsh/net/socket Module:: * The zsh/net/socket Module::
* The zsh/stat Module:: * The zsh/stat Module::
* The zsh/system Module:: * The zsh/system Module::
* The zsh/net/tcp Module:: * The zsh/net/tcp Module::
* The zsh/termcap Module:: * The zsh/termcap Module::
* The zsh/terminfo Module:: * The zsh/terminfo Module::
* The zsh/watch Module::
* The zsh/zftp Module:: * The zsh/zftp Module::
* The zsh/zle Module:: * The zsh/zle Module::
* The zsh/zleparameter Module:: * The zsh/zleparameter Module::
* The zsh/zprof Module:: * The zsh/zprof Module::
* The zsh/zpty Module:: * The zsh/zpty Module::
* The zsh/zselect Module:: * The zsh/zselect Module::
* The zsh/zutil Module:: * The zsh/zutil Module::
Calendar Function System Calendar Function System
skipping to change at line 248 skipping to change at line 251
The printed manual The printed manual
The command `texi2dvi zsh.texi' will output zsh.dvi which can then The command `texi2dvi zsh.texi' will output zsh.dvi which can then
be processed with `dvips' and optionally `gs' (Ghostscript) to be processed with `dvips' and optionally `gs' (Ghostscript) to
produce a nicely formatted printed manual. produce a nicely formatted printed manual.
The HTML manual The HTML manual
An HTML version of this manual is available at the Zsh web site An HTML version of this manual is available at the Zsh web site
via: via:
`http://zsh.sourceforge.net/Doc/'. `https://zsh.sourceforge.io/Doc/'.
(The HTML version is produced with `texi2html', which may be (The HTML version is produced with `texi2html', which may be
obtained from `http://www.nongnu.org/texi2html/'. The command is obtained from `http://www.nongnu.org/texi2html/'. The command is
`texi2html -output . -ifinfo -split=chapter -node-files zsh.texi'. `texi2html -output . -ifinfo -split=chapter -node-files zsh.texi'.
If necessary, upgrade to version 1.78 of texi2html.) If necessary, upgrade to version 1.78 of texi2html.)
For those who do not have the necessary tools to process texinfo, For those who do not have the necessary tools to process texinfo,
precompiled documentation (PostScript, dvi, PDF, info and HTML formats) precompiled documentation (PostScript, dvi, PDF, info and HTML formats)
is available from the zsh archive site or its mirrors, in the file is available from the zsh archive site or its mirrors, in the file
zsh-doc.tar.gz. (See *Note Availability:: for a list of sites.) zsh-doc.tar.gz. (See *Note Availability:: for a list of sites.)
skipping to change at line 293 skipping to change at line 296
* The Zsh Web Page:: * The Zsh Web Page::
* The Zsh Userguide:: * The Zsh Userguide::
* See Also:: * See Also::
 
File: zsh.info, Node: Author, Next: Availability, Up: Introduction File: zsh.info, Node: Author, Next: Availability, Up: Introduction
2.1 Author 2.1 Author
========== ==========
Zsh was originally written by Paul Falstad <pf@zsh.org>. Zsh is now Zsh was originally written by Paul Falstad. Zsh is now maintained by
maintained by the members of the zsh-workers mailing list the members of the zsh-workers mailing list <zsh-workers@zsh.org>. The
<zsh-workers@zsh.org>. The development is currently coordinated by development is currently coordinated by Peter Stephenson <pws@zsh.org>.
Peter Stephenson <pws@zsh.org>. The coordinator can be contacted at The coordinator can be contacted at <coordinator@zsh.org>, but matters
<coordinator@zsh.org>, but matters relating to the code should relating to the code should generally go to the mailing list.
generally go to the mailing list.
 
File: zsh.info, Node: Availability, Next: Mailing Lists, Prev: Author, Up: I ntroduction File: zsh.info, Node: Availability, Next: Mailing Lists, Prev: Author, Up: I ntroduction
2.2 Availability 2.2 Availability
================ ================
Zsh is available from the following HTTP and anonymous FTP site. Zsh is available from the following HTTP and anonymous FTP site.
`ftp://ftp.zsh.org/pub/' `ftp://ftp.zsh.org/pub/'
`https://www.zsh.org/pub/' ) `https://www.zsh.org/pub/'
The up-to-date source code is available via Git from Sourceforge. See The up-to-date source code is available via Git from Sourceforge. See
`https://sourceforge.net/projects/zsh/' for details. A summary of `https://sourceforge.net/projects/zsh/' for details. A summary of
instructions for the archive can be found at instructions for the archive can be found at
`http://zsh.sourceforge.net/'. `https://zsh.sourceforge.io/'.
 
File: zsh.info, Node: Mailing Lists, Next: The Zsh FAQ, Prev: Availability, Up: Introduction File: zsh.info, Node: Mailing Lists, Next: The Zsh FAQ, Prev: Availability, Up: Introduction
2.3 Mailing Lists 2.3 Mailing Lists
================= =================
Zsh has 3 mailing lists: Zsh has several mailing lists:
<zsh-announce@zsh.org> <zsh-announce@zsh.org>
Announcements about releases, major changes in the shell and the Announcements about releases, major changes in the shell and the
monthly posting of the Zsh FAQ. (moderated) monthly posting of the Zsh FAQ. (moderated)
<zsh-users@zsh.org> <zsh-users@zsh.org>
User discussions. User discussions.
<zsh-workers@zsh.org> <zsh-workers@zsh.org>
Hacking, development, bug reports and patches. Hacking, development, bug reports and patches.
<zsh-security@zsh.org>
Private mailing list (the general public cannot subscribe to it)
for discussing bug reports with security implications, i.e.,
potential vulnerabilities.
If you find a security problem in zsh itself, please mail this
address.
To subscribe or unsubscribe, send mail to the associated administrative To subscribe or unsubscribe, send mail to the associated administrative
address for the mailing list. address for the mailing list.
<zsh-announce-subscribe@zsh.org> <zsh-announce-subscribe@zsh.org>
<zsh-users-subscribe@zsh.org> <zsh-users-subscribe@zsh.org>
<zsh-workers-subscribe@zsh.org> <zsh-workers-subscribe@zsh.org>
<zsh-announce-unsubscribe@zsh.org> <zsh-announce-unsubscribe@zsh.org>
skipping to change at line 355 skipping to change at line 365
<zsh-users-unsubscribe@zsh.org> <zsh-users-unsubscribe@zsh.org>
<zsh-workers-unsubscribe@zsh.org> <zsh-workers-unsubscribe@zsh.org>
YOU ONLY NEED TO JOIN ONE OF THE MAILING LISTS AS THEY ARE NESTED. All YOU ONLY NEED TO JOIN ONE OF THE MAILING LISTS AS THEY ARE NESTED. All
submissions to `zsh-announce' are automatically forwarded to submissions to `zsh-announce' are automatically forwarded to
`zsh-users'. All submissions to `zsh-users' are automatically `zsh-users'. All submissions to `zsh-users' are automatically
forwarded to `zsh-workers'. forwarded to `zsh-workers'.
If you have problems subscribing/unsubscribing to any of the mailing If you have problems subscribing/unsubscribing to any of the mailing
lists, send mail to <listmaster@zsh.org>. The mailing lists are lists, send mail to <listmaster@zsh.org>.
maintained by Karsten Thygesen <karthy@kom.auc.dk>.
The mailing lists are archived; the archives can be accessed via the The mailing lists are archived; the archives can be accessed via the
administrative addresses listed above. There is also a hypertext administrative addresses listed above. There is also a hypertext
archive, maintained by Geoff Wing <gcw@zsh.org>, available at archive available at `https://www.zsh.org/mla/'.
`https://www.zsh.org/mla/'.
 
File: zsh.info, Node: The Zsh FAQ, Next: The Zsh Web Page, Prev: Mailing List s, Up: Introduction File: zsh.info, Node: The Zsh FAQ, Next: The Zsh Web Page, Prev: Mailing List s, Up: Introduction
2.4 The Zsh FAQ 2.4 The Zsh FAQ
=============== ===============
Zsh has a list of Frequently Asked Questions (FAQ), maintained by Peter Zsh has a list of Frequently Asked Questions (FAQ), maintained by Peter
Stephenson <pws@zsh.org>. It is regularly posted to the newsgroup Stephenson <pws@zsh.org>. It is regularly posted to the newsgroup
`comp.unix.shell' and the `zsh-announce' mailing list. The latest `comp.unix.shell' and the `zsh-announce' mailing list. The latest
version can be found at any of the Zsh FTP sites, or at version can be found at any of the Zsh FTP sites, or at
`http://www.zsh.org/FAQ/'. The contact address for FAQ-related matters `https://www.zsh.org/FAQ/'. The contact address for FAQ-related matters
is <faqmaster@zsh.org>. is <faqmaster@zsh.org>.
 
File: zsh.info, Node: The Zsh Web Page, Next: The Zsh Userguide, Prev: The Zs h FAQ, Up: Introduction File: zsh.info, Node: The Zsh Web Page, Next: The Zsh Userguide, Prev: The Zs h FAQ, Up: Introduction
2.5 The Zsh Web Page 2.5 The Zsh Web Page
==================== ====================
Zsh has a web page which is located at `https://www.zsh.org/'. This is Zsh has a web page which is located at `https://www.zsh.org/'. The
maintained by Karsten Thygesen <karthy@zsh.org>, of SunSITE Denmark. contact address for web-related matters is <webmaster@zsh.org>.
The contact address for web-related matters is <webmaster@zsh.org>.
 
File: zsh.info, Node: The Zsh Userguide, Next: See Also, Prev: The Zsh Web Pa ge, Up: Introduction File: zsh.info, Node: The Zsh Userguide, Next: See Also, Prev: The Zsh Web Pa ge, Up: Introduction
2.6 The Zsh Userguide 2.6 The Zsh Userguide
===================== =====================
A userguide is currently in preparation. It is intended to complement A userguide is currently in preparation. It is intended to complement
the manual, with explanations and hints on issues where the manual can the manual, with explanations and hints on issues where the manual can
be cabbalistic, hierographic, or downright mystifying (for example, the be cabbalistic, hierographic, or downright mystifying (for example, the
word `hierographic' does not exist). It can be viewed in its current word `hierographic' does not exist). It can be viewed in its current
state at `http://zsh.sourceforge.net/Guide/'. At the time of writing, state at `https://zsh.sourceforge.io/Guide/'. At the time of writing,
chapters dealing with startup files and their contents and the new chapters dealing with startup files and their contents and the new
completion system were essentially complete. completion system were essentially complete.
 
File: zsh.info, Node: See Also, Prev: The Zsh Userguide, Up: Introduction File: zsh.info, Node: See Also, Prev: The Zsh Userguide, Up: Introduction
2.7 See Also 2.7 See Also
============ ============
man page sh(1), man page csh(1), man page tcsh(1), man page rc(1), man sh(1), csh(1), tcsh(1), rc(1), bash(1), ksh(1)
page bash(1), man page ksh(1)
`IEEE Standard for information Technology - Portable Operating System `IEEE Standard for information Technology - Portable Operating System
Interface (POSIX) - Part 2: Shell and Utilities', IEEE Inc, 1993, ISBN Interface (POSIX) - Part 2: Shell and Utilities', IEEE Inc, 1993, ISBN
1-55937-255-9. 1-55937-255-9.
 
File: zsh.info, Node: Roadmap, Next: Invocation, Prev: Introduction, Up: Top File: zsh.info, Node: Roadmap, Next: Invocation, Prev: Introduction, Up: Top
3 Roadmap 3 Roadmap
********* *********
skipping to change at line 462 skipping to change at line 468
default is quite small (30 lines). See the description of the shell default is quite small (30 lines). See the description of the shell
variables (referred to in the documentation as parameters) HISTFILE, variables (referred to in the documentation as parameters) HISTFILE,
HISTSIZE and SAVEHIST in *Note Parameters Used By The Shell::. Note HISTSIZE and SAVEHIST in *Note Parameters Used By The Shell::. Note
that it's currently only possible to read and write files saving history that it's currently only possible to read and write files saving history
when the shell is interactive, i.e. it does not work from scripts. when the shell is interactive, i.e. it does not work from scripts.
The shell now supports the UTF-8 character set (and also others if The shell now supports the UTF-8 character set (and also others if
supported by the operating system). This is (mostly) handled supported by the operating system). This is (mostly) handled
transparently by the shell, but the degree of support in terminal transparently by the shell, but the degree of support in terminal
emulators is variable. There is some discussion of this in the shell emulators is variable. There is some discussion of this in the shell
FAQ, `http://www.zsh.org/FAQ/'. Note in particular that for combining FAQ, `https://www.zsh.org/FAQ/'. Note in particular that for combining
characters to be handled the option COMBINING_CHARS needs to be set. characters to be handled the option COMBINING_CHARS needs to be set.
Because the shell is now more sensitive to the definition of the Because the shell is now more sensitive to the definition of the
character set, note that if you are upgrading from an older version of character set, note that if you are upgrading from an older version of
the shell you should ensure that the appropriate variable, either LANG the shell you should ensure that the appropriate variable, either LANG
(to affect all aspects of the shell's operation) or LC_CTYPE (to affect (to affect all aspects of the shell's operation) or LC_CTYPE (to affect
only the handling of character sets) is set to an appropriate value. only the handling of character sets) is set to an appropriate value.
This is true even if you are using a single-byte character set This is true even if you are using a single-byte character set
including extensions of ASCII such as ISO-8859-1 or ISO-8859-15. See including extensions of ASCII such as ISO-8859-1 or ISO-8859-15. See
the description of LC_CTYPE in *Note Parameters::. the description of LC_CTYPE in *Note Parameters::.
skipping to change at line 723 skipping to change at line 729
by which it was invoked, excluding any initial `r' (assumed to stand by which it was invoked, excluding any initial `r' (assumed to stand
for `restricted'), and if that is `b', `s' or `k' it will emulate `sh' for `restricted'), and if that is `b', `s' or `k' it will emulate `sh'
or `ksh'. Furthermore, if invoked as su (which happens on certain or `ksh'. Furthermore, if invoked as su (which happens on certain
systems when the shell is executed by the su command), the shell will systems when the shell is executed by the su command), the shell will
try to find an alternative name from the SHELL environment variable and try to find an alternative name from the SHELL environment variable and
perform emulation based on that. perform emulation based on that.
In `sh' and `ksh' compatibility modes the following parameters are not In `sh' and `ksh' compatibility modes the following parameters are not
special and not initialized by the shell: ARGC, argv, cdpath, fignore, special and not initialized by the shell: ARGC, argv, cdpath, fignore,
fpath, HISTCHARS, mailpath, MANPATH, manpath, path, prompt, PROMPT, fpath, HISTCHARS, mailpath, MANPATH, manpath, path, prompt, PROMPT,
PROMPT2, PROMPT3, PROMPT4, psvar, status, watch. PROMPT2, PROMPT3, PROMPT4, psvar, status.
The usual zsh startup/shutdown scripts are not executed. Login shells The usual zsh startup/shutdown scripts are not executed. Login shells
source /etc/profile followed by $HOME/.profile. If the ENV environment source /etc/profile followed by $HOME/.profile. If the ENV environment
variable is set on invocation, $ENV is sourced after the profile variable is set on invocation, $ENV is sourced after the profile
scripts. The value of ENV is subjected to parameter expansion, command scripts. The value of ENV is subjected to parameter expansion, command
substitution, and arithmetic expansion before being interpreted as a substitution, and arithmetic expansion before being interpreted as a
pathname. Note that the PRIVILEGED option also affects the execution pathname. Note that the PRIVILEGED option also affects the execution
of startup files. of startup files.
The following options are set if the shell is invoked as sh or ksh: The following options are set if the shell is invoked as sh or ksh:
NO_BAD_PATTERN, NO_BANG_HIST, NO_BG_NICE, NO_EQUALS, NO_BAD_PATTERN, NO_BANG_HIST, NO_BG_NICE, NO_EQUALS,
NO_FUNCTION_ARGZERO, GLOB_SUBST, NO_GLOBAL_EXPORT, NO_HUP, NO_FUNCTION_ARGZERO, GLOB_SUBST, NO_GLOBAL_EXPORT, NO_HUP,
INTERACTIVE_COMMENTS, KSH_ARRAYS, NO_MULTIOS, NO_NOMATCH, NO_NOTIFY, INTERACTIVE_COMMENTS, KSH_ARRAYS, NO_MULTIOS, NO_NOMATCH, NO_NOTIFY,
POSIX_BUILTINS, NO_PROMPT_PERCENT, RM_STAR_SILENT, SH_FILE_EXPANSION, POSIX_BUILTINS, NO_PROMPT_PERCENT, RM_STAR_SILENT, SH_FILE_EXPANSION,
SH_GLOB, SH_OPTION_LETTERS, SH_WORD_SPLIT. Additionally the BSD_ECHO SH_GLOB, SH_OPTION_LETTERS, SH_WORD_SPLIT. Additionally the BSD_ECHO
and IGNORE_BRACES options are set if zsh is invoked as sh. Also, the and IGNORE_BRACES options are set if zsh is invoked as sh. Also, the
KSH_OPTION_PRINT, LOCAL_OPTIONS, PROMPT_BANG, PROMPT_SUBST and KSH_OPTION_PRINT, LOCAL_OPTIONS, PROMPT_BANG, PROMPT_SUBST and
SINGLE_LINE_ZLE options are set if zsh is invoked as ksh. SINGLE_LINE_ZLE options are set if zsh is invoked as ksh.
Please note that, whilst reasonable efforts are taken to address
incompatibilities when they arise, zsh does not guarantee complete
emulation of other shells, nor POSIX compliance. For more information on
the differences between zsh and other shells, please refer to chapterĀ 2
of the shell FAQ, `https://www.zsh.org/FAQ/'.
 
File: zsh.info, Node: Restricted Shell, Prev: Compatibility, Up: Invocation File: zsh.info, Node: Restricted Shell, Prev: Compatibility, Up: Invocation
4.3 Restricted Shell 4.3 Restricted Shell
==================== ====================
When the basename of the command used to invoke zsh starts with the When the basename of the command used to invoke zsh starts with the
letter `r' or the `-r' command line option is supplied at invocation, letter `r' or the `-r' command line option is supplied at invocation,
the shell becomes restricted. Emulation mode is determined after the shell becomes restricted. Emulation mode is determined after
stripping the letter `r' from the invocation name. The following are stripping the letter `r' from the invocation name. The following are
skipping to change at line 1152 skipping to change at line 1164
line consists of the number of one of the listed WORDs, then the line consists of the number of one of the listed WORDs, then the
parameter NAME is set to the WORD corresponding to this number. parameter NAME is set to the WORD corresponding to this number.
If this line is empty, the selection list is printed again. If this line is empty, the selection list is printed again.
Otherwise, the value of the parameter NAME is set to null. The Otherwise, the value of the parameter NAME is set to null. The
contents of the line read from standard input is saved in the contents of the line read from standard input is saved in the
parameter REPLY. LIST is executed for each selection until a parameter REPLY. LIST is executed for each selection until a
break or end-of-file is encountered. break or end-of-file is encountered.
( LIST ) ( LIST )
Execute LIST in a subshell. Traps set by the trap builtin are Execute LIST in a subshell. Traps set by the trap builtin are
reset to their default values while executing LIST. reset to their default values while executing LIST; an exception
is that ignored signals will continue to be ignored if the option
POSIXTRAPS is set.
{ LIST } { LIST }
Execute LIST. Execute LIST.
{ TRY-LIST } always { ALWAYS-LIST } { TRY-LIST } always { ALWAYS-LIST }
First execute TRY-LIST. Regardless of errors, or break or First execute TRY-LIST. Regardless of errors, or break or
continue commands encountered within TRY-LIST, execute continue commands encountered within TRY-LIST, execute
ALWAYS-LIST. Execution then continues from the result of the ALWAYS-LIST. Execution then continues from the result of the
execution of TRY-LIST; in other words, any error, or break or execution of TRY-LIST; in other words, any error, or break or
continue command is treated in the normal way, as if ALWAYS-LIST continue command is treated in the normal way, as if ALWAYS-LIST
skipping to change at line 1214 skipping to change at line 1228
} }
# The error condition has been reset. # The error condition has been reset.
When a try block occurs outside of any function, a return or a When a try block occurs outside of any function, a return or a
exit encountered in TRY-LIST does _not_ cause the execution of exit encountered in TRY-LIST does _not_ cause the execution of
ALWAYS-LIST. Instead, the shell exits immediately after any EXIT ALWAYS-LIST. Instead, the shell exits immediately after any EXIT
trap has been executed. Otherwise, a return command encountered trap has been executed. Otherwise, a return command encountered
in TRY-LIST will cause the execution of ALWAYS-LIST, just like in TRY-LIST will cause the execution of ALWAYS-LIST, just like
break and continue. break and continue.
function WORD ... [ () ] [ TERM ] { LIST } function [ -T ] WORD ... [ () ] [ TERM ] { LIST }
WORD ... () [ TERM ] { LIST } WORD ... () [ TERM ] { LIST }
WORD ... () [ TERM ] COMMAND WORD ... () [ TERM ] COMMAND
where TERM is one or more newline or ;. Define a function which where TERM is one or more newline or ;. Define a function which
is referenced by any one of WORD. Normally, only one WORD is is referenced by any one of WORD. Normally, only one WORD is
provided; multiple WORDs are usually only useful for setting traps. provided; multiple WORDs are usually only useful for setting traps.
The body of the function is the LIST between the { and }. See The body of the function is the LIST between the { and }. See
*Note Functions::. *Note Functions::.
The options of function have the following meanings:
-T
Enable tracing for this function, as though with functions
-T. See the documentation of the -f option to the typeset
builtin, in *Note Shell Builtin Commands::.
If the option SH_GLOB is set for compatibility with other shells, If the option SH_GLOB is set for compatibility with other shells,
then whitespace may appear between the left and right parentheses then whitespace may appear between the left and right parentheses
when there is a single WORD; otherwise, the parentheses will be when there is a single WORD; otherwise, the parentheses will be
treated as forming a globbing pattern in that case. treated as forming a globbing pattern in that case.
In any of the forms above, a redirection may appear outside the In any of the forms above, a redirection may appear outside the
function body, for example function body, for example
func() { ... } 2>&1 func() { ... } 2>&1
skipping to change at line 1267 skipping to change at line 1288
programmers; they should not be used anywhere that portability of shell programmers; they should not be used anywhere that portability of shell
code is a concern. code is a concern.
The short versions below only work if SUBLIST is of the form `{ LIST }' The short versions below only work if SUBLIST is of the form `{ LIST }'
or if the SHORT_LOOPS option is set. For the if, while and until or if the SHORT_LOOPS option is set. For the if, while and until
commands, in both these cases the test part of the loop must also be commands, in both these cases the test part of the loop must also be
suitably delimited, such as by `[[ ... ]]' or `(( ... ))', else the end suitably delimited, such as by `[[ ... ]]' or `(( ... ))', else the end
of the test will not be recognized. For the for, repeat, case and of the test will not be recognized. For the for, repeat, case and
select commands no such special form for the arguments is necessary, select commands no such special form for the arguments is necessary,
but the other condition (the special form of SUBLIST or use of the but the other condition (the special form of SUBLIST or use of the
SHORT_LOOPS option) still applies. SHORT_LOOPS option) still applies. The SHORT_REPEAT option is
available to enable the short version only for the repeat command.
if LIST { LIST } [ elif LIST { LIST } ] ... [ else { LIST } ] if LIST { LIST } [ elif LIST { LIST } ] ... [ else { LIST } ]
An alternate form of if. The rules mean that An alternate form of if. The rules mean that
if [[ -o ignorebraces ]] { if [[ -o ignorebraces ]] {
print yes print yes
} }
works, but works, but
skipping to change at line 1432 skipping to change at line 1454
File: zsh.info, Node: Aliasing, Next: Quoting, Prev: Comments, Up: Shell Gra mmar File: zsh.info, Node: Aliasing, Next: Quoting, Prev: Comments, Up: Shell Gra mmar
6.8 Aliasing 6.8 Aliasing
============ ============
Every eligible _word_ in the shell input is checked to see if there is Every eligible _word_ in the shell input is checked to see if there is
an alias defined for it. If so, it is replaced by the text of the an alias defined for it. If so, it is replaced by the text of the
alias if it is in command position (if it could be the first word of a alias if it is in command position (if it could be the first word of a
simple command), or if the alias is global. If the replacement text simple command), or if the alias is global. If the replacement text
ends with a space, the next word in the shell input is always eligible ends with a space, the next word in the shell input is always eligible
for purposes of alias expansion. An alias is defined using the alias for purposes of alias expansion.
builtin; global aliases may be defined using the -g option to that
builtin. It is an error for the function name, WORD, in the sh-compatible
function definition syntax `WORD () ...' to be a word that resulted
from alias expansion, unless the ALIAS_FUNC_DEF option is set.
An alias is defined using the alias builtin; global aliases may be
defined using the -g option to that builtin.
A _word_ is defined as: A _word_ is defined as:
* Any plain string or glob pattern * Any plain string or glob pattern
* Any quoted string, using any quoting method (note that the quotes * Any quoted string, using any quoting method (note that the quotes
must be part of the alias definition for this to be eligible) must be part of the alias definition for this to be eligible)
* Any parameter reference or command substitution * Any parameter reference or command substitution
skipping to change at line 1459 skipping to change at line 1486
* With global aliasing, any command separator, any redirection * With global aliasing, any command separator, any redirection
operator, and `(' or `)' when not part of a glob pattern operator, and `(' or `)' when not part of a glob pattern
Alias expansion is done on the shell input before any other expansion Alias expansion is done on the shell input before any other expansion
except history expansion. Therefore, if an alias is defined for the except history expansion. Therefore, if an alias is defined for the
word foo, alias expansion may be avoided by quoting part of the word, word foo, alias expansion may be avoided by quoting part of the word,
e.g. \foo. Any form of quoting works, although there is nothing to e.g. \foo. Any form of quoting works, although there is nothing to
prevent an alias being defined for the quoted form such as \foo as well. prevent an alias being defined for the quoted form such as \foo as well.
In particular, note that quoting must be used when using unalias to
remove global aliases:
% alias -g foo=bar
% unalias foo
unalias: no such hash table element: bar
% unalias \foo
%
When POSIX_ALIASES is set, only plain unquoted strings are eligible for When POSIX_ALIASES is set, only plain unquoted strings are eligible for
aliasing. The alias builtin does not reject ineligible aliases, but aliasing. The alias builtin does not reject ineligible aliases, but
they are not expanded. they are not expanded.
For use with completion, which would remove an initial backslash For use with completion, which would remove an initial backslash
followed by a character that isn't special, it may be more convenient followed by a character that isn't special, it may be more convenient
to quote the word by starting with a single quote, i.e. 'foo; to quote the word by starting with a single quote, i.e. 'foo;
completion will automatically add the trailing single quote. completion will automatically add the trailing single quote.
6.8.1 Alias difficulties 6.8.1 Alias difficulties
skipping to change at line 1506 skipping to change at line 1542
alias echobar='echo bar'; echobar alias echobar='echo bar'; echobar
This prints a message that the command echobar could not be found. This prints a message that the command echobar could not be found.
This happens because aliases are expanded when the code is read in; the This happens because aliases are expanded when the code is read in; the
entire line is read in one go, so that when echobar is executed it is entire line is read in one go, so that when echobar is executed it is
too late to expand the newly defined alias. This is often a problem in too late to expand the newly defined alias. This is often a problem in
shell scripts, functions, and code executed with `source' or `.'. shell scripts, functions, and code executed with `source' or `.'.
Consequently, use of functions rather than aliases is recommended in Consequently, use of functions rather than aliases is recommended in
non-interactive code. non-interactive code.
Note also the unhelpful interaction of aliases and function definitions:
alias func='noglob func'
func() {
echo Do something with $*
}
Because aliases are expanded in function definitions, this causes the
following command to be executed:
noglob func() {
echo Do something with $*
}
which defines noglob as well as func as functions with the body given.
To avoid this, either quote the name func or use the alternative
function definition form `function func'. Ensuring the alias is
defined after the function works but is problematic if the code
fragment might be re-executed.
 
File: zsh.info, Node: Quoting, Prev: Aliasing, Up: Shell Grammar File: zsh.info, Node: Quoting, Prev: Aliasing, Up: Shell Grammar
6.9 Quoting 6.9 Quoting
=========== ===========
A character may be _quoted_ (that is, made to stand for itself) by A character may be _quoted_ (that is, made to stand for itself) by
preceding it with a `\'. `\' followed by a newline is ignored. preceding it with a `\'. `\' followed by a newline is ignored.
A string enclosed between `$'' and `'' is processed the same way as the A string enclosed between `$'' and `'' is processed the same way as the
skipping to change at line 1629 skipping to change at line 1645
Quotes in the form $'...' have their standard effect of expanding Quotes in the form $'...' have their standard effect of expanding
backslashed references to special characters. backslashed references to special characters.
If <<- is used, then all leading tabs are stripped from WORD and If <<- is used, then all leading tabs are stripped from WORD and
from the document. from the document.
<<< WORD <<< WORD
Perform shell expansion on WORD and pass the result to standard Perform shell expansion on WORD and pass the result to standard
input. This is known as a _here-string_. Compare the use of WORD input. This is known as a _here-string_. Compare the use of WORD
in here-documents above, where WORD does not undergo shell in here-documents above, where WORD does not undergo shell
expansion. expansion. The result will have a trailing newline after it.
<& NUMBER <& NUMBER
>& NUMBER >& NUMBER
The standard input/output is duplicated from file descriptor The standard input/output is duplicated from file descriptor
NUMBER (see man page dup2(2)). NUMBER (see dup2(2)).
<& - <& -
>& - >& -
Close the standard input/output. Close the standard input/output.
<& p <& p
>& p >& p
The input/output from/to the coprocess is moved to the standard The input/output from/to the coprocess is moved to the standard
input/output. input/output.
skipping to change at line 1895 skipping to change at line 1911
8 Command Execution 8 Command Execution
******************* *******************
If a command name contains no slashes, the shell attempts to locate it. If a command name contains no slashes, the shell attempts to locate it.
If there exists a shell function by that name, the function is invoked If there exists a shell function by that name, the function is invoked
as described in *Note Functions::. If there exists a shell builtin by as described in *Note Functions::. If there exists a shell builtin by
that name, the builtin is invoked. that name, the builtin is invoked.
Otherwise, the shell searches each element of $path for a directory Otherwise, the shell searches each element of $path for a directory
containing an executable file by that name. If the search is containing an executable file by that name.
unsuccessful, the shell prints an error message and returns a nonzero
exit status. If execution fails: an error message is printed, and one of the
following values is returned.
127
The search was unsuccessful. The error message is `command not
found: CMD'.
126
The executable file has insufficient permissions, is a directory
or special file, or is not a script and is in a format
unrecognized by the operating system. The exact conditions and
error message are operating system-dependent; see execve(2).
If execution fails because the file is not in executable format, and If execution fails because the file is not in executable format, and
the file is not a directory, it is assumed to be a shell script. the file is not a directory, it is assumed to be a shell script.
/bin/sh is spawned to execute it. If the program is a file beginning /bin/sh is spawned to execute it. If the program is a file beginning
with `#!', the remainder of the first line specifies an interpreter for with `#!', the remainder of the first line specifies an interpreter for
the program. The shell will execute the specified interpreter on the program. The shell will execute the specified interpreter on
operating systems that do not handle this executable format in the operating systems that do not handle this executable format in the
kernel. kernel.
If no external command is found but a function command_not_found_handler If no external command is found but a function command_not_found_handler
exists the shell executes this function with all command line exists the shell executes this function with all command line
arguments. The return status of the function becomes the status of the arguments. The return status of the function becomes the status of the
command. If the function wishes to mimic the behaviour of the shell command. Note that the handler is executed in a subshell forked to
when the command is not found, it should print the message `command not execute an external command, hence changes to directories, shell
found: CMD' to standard error and return status 127. Note that the parameters, etc. have no effect on the main shell.
handler is executed in a subshell forked to execute an external
command, hence changes to directories, shell parameters, etc. have no
effect on the main shell.
 
File: zsh.info, Node: Functions, Next: Jobs & Signals, Prev: Command Executio n, Up: Top File: zsh.info, Node: Functions, Next: Jobs & Signals, Prev: Command Executio n, Up: Top
9 Functions 9 Functions
*********** ***********
Shell functions are defined with the function reserved word or the Shell functions are defined with the function reserved word or the
special syntax `FUNCNAME ()'. Shell functions are read in and stored special syntax `FUNCNAME ()'. Shell functions are read in and stored
internally. Alias names are resolved when the function is read. internally. Alias names are resolved when the function is read.
skipping to change at line 2112 skipping to change at line 2136
===================== =====================
Certain functions, if defined, have special meaning to the shell. Certain functions, if defined, have special meaning to the shell.
9.3.1 Hook Functions 9.3.1 Hook Functions
-------------------- --------------------
For the functions below, it is possible to define an array that has the For the functions below, it is possible to define an array that has the
same name as the function with `_functions' appended. Any element in same name as the function with `_functions' appended. Any element in
such an array is taken as the name of a function to execute; it is such an array is taken as the name of a function to execute; it is
executed in the same context and with the same arguments as the basic executed in the same context and with the same arguments and same
function. For example, if $chpwd_functions is an array containing the initial value of $? as the basic function. For example, if
values `mychpwd', `chpwd_save_dirstack', then the shell attempts to $chpwd_functions is an array containing the values `mychpwd',
execute the functions `chpwd', `mychpwd' and `chpwd_save_dirstack', in `chpwd_save_dirstack', then the shell attempts to execute the functions
that order. Any function that does not exist is silently ignored. A `chpwd', `mychpwd' and `chpwd_save_dirstack', in that order. Any
function found by this mechanism is referred to elsewhere as a `hook function that does not exist is silently ignored. A function found by
function'. An error in any function causes subsequent functions not to this mechanism is referred to elsewhere as a _hook function_. An error
be run. Note further that an error in a precmd hook causes an in any function causes subsequent functions not to be run. Note
immediately following periodic function not to run (though it may run further that an error in a precmd hook causes an immediately following
at the next opportunity). periodic function not to run (though it may run at the next
opportunity).
chpwd chpwd
Executed whenever the current working directory is changed. Executed whenever the current working directory is changed.
periodic periodic
If the parameter PERIOD is set, this function is executed every If the parameter PERIOD is set, this function is executed every
$PERIOD seconds, just before a prompt. Note that if multiple $PERIOD seconds, just before a prompt. Note that if multiple
functions are defined using the array periodic_functions only one functions are defined using the array periodic_functions only one
period is applied to the complete set of functions, and the period is applied to the complete set of functions, and the
scheduled time is not reset if the list of functions is altered. scheduled time is not reset if the list of functions is altered.
skipping to change at line 2168 skipping to change at line 2193
versions of the shell) the history line will not be saved, versions of the shell) the history line will not be saved,
although it lingers in the history until the next line is although it lingers in the history until the next line is
executed, allowing you to reuse or edit it immediately. executed, allowing you to reuse or edit it immediately.
If any of the hook functions returns status 2 the history line If any of the hook functions returns status 2 the history line
will be saved on the internal history list, but not written to the will be saved on the internal history list, but not written to the
history file. In case of a conflict, the first non-zero status history file. In case of a conflict, the first non-zero status
value is taken. value is taken.
A hook function may call `fc -p ...' to switch the history context A hook function may call `fc -p ...' to switch the history context
so that the history is saved in a different file from the that in so that the history is saved in a different file from that in the
the global HISTFILE parameter. This is handled specially: the global HISTFILE parameter. This is handled specially: the history
history context is automatically restored after the processing of context is automatically restored after the processing of the
the history line is finished. history line is finished.
The following example function works with one of the options The following example function works with one of the options
INC_APPEND_HISTORY or SHARE_HISTORY set, in order that the line is INC_APPEND_HISTORY or SHARE_HISTORY set, in order that the line is
written out immediately after the history entry is added. It first written out immediately after the history entry is added. It first
adds the history line to the normal history with the newline adds the history line to the normal history with the newline
stripped, which is usually the correct behaviour. Then it stripped, which is usually the correct behaviour. Then it
switches the history context so that the line will be written to a switches the history context so that the line will be written to a
history file in the current directory. history file in the current directory.
zshaddhistory() { zshaddhistory() {
skipping to change at line 2385 skipping to change at line 2410
triggers any trap set for CHLD. triggers any trap set for CHLD.
When you try to leave the shell while jobs are running or suspended, When you try to leave the shell while jobs are running or suspended,
you will be warned that `You have suspended (running) jobs'. You may you will be warned that `You have suspended (running) jobs'. You may
use the jobs command to see what they are. If you do this or use the jobs command to see what they are. If you do this or
immediately try to exit again, the shell will not warn you a second immediately try to exit again, the shell will not warn you a second
time; the suspended jobs will be terminated, and the running jobs will time; the suspended jobs will be terminated, and the running jobs will
be sent a SIGHUP signal, if the HUP option is set. be sent a SIGHUP signal, if the HUP option is set.
To avoid having the shell terminate the running jobs, either use the To avoid having the shell terminate the running jobs, either use the
`nohup' command (see man page nohup(1)) or the disown builtin. nohup(1) command or the disown builtin.
10.2 Signals 10.2 Signals
============ ============
The INT and QUIT signals for an invoked command are ignored if the The INT and QUIT signals for an invoked command are ignored if the
command is followed by `&' and the MONITOR option is not active. The command is followed by `&' and the MONITOR option is not active. The
shell itself always ignores the QUIT signal. Otherwise, signals have shell itself always ignores the QUIT signal. Otherwise, signals have
the values inherited by the shell from its parent (but see the TRAPNAL the values inherited by the shell from its parent (but see the TRAPNAL
special functions in *Note Functions::). special functions in *Note Functions::).
Certain jobs are run asynchronously by the shell other than those Certain jobs are run asynchronously by the shell other than those
explicitly put into the background; even in cases where the shell would explicitly put into the background; even in cases where the shell would
usually wait for such jobs, an explicit exit command or exit due to the usually wait for such jobs, an explicit exit command or exit due to the
option ERR_EXIT will cause the shell to exit without waiting. Examples option ERR_EXIT will cause the shell to exit without waiting. Examples
of such asynchronous jobs are process substitution, see *Note Process of such asynchronous jobs are process substitution, see *Note Process
Substitution::, and the handler processes for multios, see the section Substitution::, and the handler processes for multios, see the section
Multios in *Note Redirection::. _Multios_ in *Note Redirection::.
 
File: zsh.info, Node: Arithmetic Evaluation, Next: Conditional Expressions, P rev: Jobs & Signals, Up: Top File: zsh.info, Node: Arithmetic Evaluation, Next: Conditional Expressions, P rev: Jobs & Signals, Up: Top
11 Arithmetic Evaluation 11 Arithmetic Evaluation
************************ ************************
The shell can perform integer and floating point arithmetic, either The shell can perform integer and floating point arithmetic, either
using the builtin let, or via a substitution of the form $((...)). For using the builtin let, or via a substitution of the form $((...)). For
integers, the shell is usually compiled to use 8-byte precision where integers, the shell is usually compiled to use 8-byte precision where
this is available, otherwise precision is 4 bytes. This can be tested, this is available, otherwise precision is 4 bytes. This can be tested,
for example, by giving the command `print - $(( 12345678901 ))'; if the for example, by giving the command `print - $(( 12345678901 ))'; if the
number appears unchanged, the precision is at least 8 bytes. Floating number appears unchanged, the precision is at least 8 bytes. Floating
point arithmetic always uses the `double' type with whatever point arithmetic always uses the `double' type with whatever
corresponding precision is provided by the compiler and the library. corresponding precision is provided by the compiler and the library.
The let builtin command takes arithmetic expressions as arguments; each The let builtin command takes arithmetic expressions as arguments; each
is evaluated separately. Since many of the arithmetic operators, as is evaluated separately. Since many of the arithmetic operators, as
well as spaces, require quoting, an alternative form is provided: for well as spaces, require quoting, an alternative form is provided: for
any command which begins with a `((', all the characters until a any command which begins with a `((', all the characters until a
matching `))' are treated as a quoted expression and arithmetic matching `))' are treated as a double-quoted expression and arithmetic
expansion performed as for an argument of let. More precisely, expansion performed as for an argument of let. More precisely,
`((...))' is equivalent to `let "..."'. The return status is 0 if the `((...))' is equivalent to `let "..."'. The return status is 0 if the
arithmetic value of the expression is non-zero, 1 if it is zero, and 2 arithmetic value of the expression is non-zero, 1 if it is zero, and 2
if an error occurred. if an error occurred.
For example, the following statement For example, the following statement
(( val = 2 + 1 )) (( val = 2 + 1 ))
is equivalent to is equivalent to
skipping to change at line 3126 skipping to change at line 3151
%* %*
Current time of day in 24-hour format, with seconds. Current time of day in 24-hour format, with seconds.
%w %w
The date in DAY-DD format. The date in DAY-DD format.
%W %W
The date in MM/DD/YY format. The date in MM/DD/YY format.
%D{STRING} %D{STRING}
STRING is formatted using the strftime function. See man page STRING is formatted using the strftime function. See strftime(3)
strftime(3) for more details. Various zsh extensions provide for more details. Various zsh extensions provide numbers with no
numbers with no leading zero or space if the number is a single leading zero or space if the number is a single digit:
digit:
%f %f
a day of the month a day of the month
%K %K
the hour of the day on the 24-hour clock the hour of the day on the 24-hour clock
%L %L
the hour of the day on the 12-hour clock the hour of the day on the 12-hour clock
skipping to change at line 3659 skipping to change at line 3683
l l
Convert the words to all lowercase. Convert the words to all lowercase.
p p
Print the new command but do not execute it. Only works with Print the new command but do not execute it. Only works with
history expansion. history expansion.
P P
Turn a file name into an absolute path, like realpath(3). The Turn a file name into an absolute path, like realpath(3). The
resulting path will be absolute, have neither `.' nor `..' resulting path will be absolute, will refer to the same directory
components, and refer to the same directory entry as the input entry as the input filename, and none of its components will be
filename. symbolic links or equal to `.' or `..'.
Unlike realpath(3), non-existent trailing components are permitted Unlike realpath(3), non-existent trailing components are permitted
and preserved. and preserved.
q q
Quote the substituted words, escaping further substitutions. Works Quote the substituted words, escaping further substitutions. Works
with history expansion and parameter expansion, though for with history expansion and parameter expansion, though for
parameters it is only useful if the resulting text is to be parameters it is only useful if the resulting text is to be
re-evaluated such as by eval. re-evaluated such as by eval.
skipping to change at line 3837 skipping to change at line 3861
paste <(cut -f1 FILE1) <(cut -f3 FILE2) | paste <(cut -f1 FILE1) <(cut -f3 FILE2) |
tee >(PROCESS1) >(PROCESS2) >/dev/null tee >(PROCESS1) >(PROCESS2) >/dev/null
cuts fields 1 and 3 from the files FILE1 and FILE2 respectively, pastes cuts fields 1 and 3 from the files FILE1 and FILE2 respectively, pastes
the results together, and sends it to the processes PROCESS1 and the results together, and sends it to the processes PROCESS1 and
PROCESS2. PROCESS2.
If =(...) is used instead of <(...), then the file passed as an If =(...) is used instead of <(...), then the file passed as an
argument will be the name of a temporary file containing the output of argument will be the name of a temporary file containing the output of
the LIST process. This may be used instead of the < form for a program the LIST process. This may be used instead of the < form for a program
that expects to lseek (see man page lseek(2)) on the input file. that expects to lseek (see lseek(2)) on the input file.
There is an optimisation for substitutions of the form =(<<<ARG), where There is an optimisation for substitutions of the form =(<<<ARG), where
ARG is a single-word argument to the here-string redirection <<<. This ARG is a single-word argument to the here-string redirection <<<. This
form produces a file name containing the value of ARG after any form produces a file name containing the value of ARG after any
substitutions have been performed. This is handled entirely within the substitutions have been performed. This is handled entirely within the
current shell. This is effectively the reverse of the special form current shell. This is effectively the reverse of the special form
$(<ARG) which treats ARG as a file name and replaces it with the file's $(<ARG) which treats ARG as a file name and replaces it with the file's
contents. contents.
The = form is useful as both the /dev/fd and the named pipe The = form is useful as both the /dev/fd and the named pipe
implementation of <(...) have drawbacks. In the former case, some implementation of <(...) have drawbacks. In the former case, some
programmes may automatically close the file descriptor in question programmes may automatically close the file descriptor in question
before examining the file on the command line, particularly if this is before examining the file on the command line, particularly if this is
necessary for security reasons such as when the programme is running necessary for security reasons such as when the programme is running
setuid. In the second case, if the programme does not actually open setuid. In the second case, if the programme does not actually open
the file, the subshell attempting to read from or write to the pipe the file, the subshell attempting to read from or write to the pipe
will (in a typical implementation, different operating systems may have will (in a typical implementation, different operating systems may have
different behaviour) block for ever and have to be killed explicitly. different behaviour) block for ever and have to be killed explicitly.
In both cases, the shell actually supplies the information using a In both cases, the shell actually supplies the information using a
pipe, so that programmes that expect to lseek (see man page lseek(2)) pipe, so that programmes that expect to lseek (see lseek(2)) on the
on the file will not work. file will not work.
Also note that the previous example can be more compactly and Also note that the previous example can be more compactly and
efficiently written (provided the MULTIOS option is set) as: efficiently written (provided the MULTIOS option is set) as:
paste <(cut -f1 FILE1) <(cut -f3 FILE2) > >(PROCESS1) > >(PROCESS2) paste <(cut -f1 FILE1) <(cut -f3 FILE2) > >(PROCESS1) > >(PROCESS2)
The shell uses pipes instead of FIFOs to implement the latter two The shell uses pipes instead of FIFOs to implement the latter two
process substitutions in the above example. process substitutions in the above example.
There is an additional problem with >(PROCESS); when this is attached There is an additional problem with >(PROCESS); when this is attached
skipping to change at line 4207 skipping to change at line 4231
Note that `^', `=', and `~', below, must appear to the left of `#' Note that `^', `=', and `~', below, must appear to the left of `#'
when these forms are combined. when these forms are combined.
If the option POSIX_IDENTIFIERS is not set, and SPEC is a simple If the option POSIX_IDENTIFIERS is not set, and SPEC is a simple
name, then the braces are optional; this is true even for special name, then the braces are optional; this is true even for special
parameters so e.g. $#- and $#* take the length of the string $- parameters so e.g. $#- and $#* take the length of the string $-
and the array $* respectively. If POSIX_IDENTIFIERS is set, then and the array $* respectively. If POSIX_IDENTIFIERS is set, then
braces are required for the # to be treated in this fashion. braces are required for the # to be treated in this fashion.
${^SPEC} ${^SPEC}
${^^SPEC}
Turn on the RC_EXPAND_PARAM option for the evaluation of SPEC; if Turn on the RC_EXPAND_PARAM option for the evaluation of SPEC; if
the `^' is doubled, turn it off. When this option is set, array the `^' is doubled, turn it off. When this option is set, array
expansions of the form FOO${XX}BAR, where the parameter XX is set expansions of the form FOO${XX}BAR, where the parameter XX is set
to (A B C), are substituted with `FOOABAR FOOBBAR FOOCBAR' instead to (A B C), are substituted with `FOOABAR FOOBBAR FOOCBAR' instead
of the default `FOOA B CBAR'. Note that an empty array will of the default `FOOA B CBAR'. Note that an empty array will
therefore cause all arguments to be removed. therefore cause all arguments to be removed.
Internally, each such expansion is converted into the equivalent Internally, each such expansion is converted into the equivalent
list for brace expansion. E.g., ${^var} becomes list for brace expansion. E.g., ${^var} becomes
{$var[1],$var[2],...}, and is processed as described in *Note {$var[1],$var[2],...}, and is processed as described in *Note
Brace Expansion:: below: note, however, the expansion happens Brace Expansion:: below: note, however, the expansion happens
immediately, with any explicit brace expansion happening later. immediately, with any explicit brace expansion happening later.
If word splitting is also in effect the $var[N] may themselves be If word splitting is also in effect the $var[N] may themselves be
split into different list elements. split into different list elements.
${=SPEC} ${=SPEC}
${==SPEC}
Perform word splitting using the rules for SH_WORD_SPLIT during the Perform word splitting using the rules for SH_WORD_SPLIT during the
evaluation of SPEC, but regardless of whether the parameter evaluation of SPEC, but regardless of whether the parameter
appears in double quotes; if the `=' is doubled, turn it off. This appears in double quotes; if the `=' is doubled, turn it off. This
forces parameter expansions to be split into separate words before forces parameter expansions to be split into separate words before
substitution, using IFS as a delimiter. This is done by default substitution, using IFS as a delimiter. This is done by default
in most other shells. in most other shells.
Note that splitting is applied to WORD in the assignment forms of Note that splitting is applied to WORD in the assignment forms of
SPEC _before_ the assignment to NAME is performed. This affects SPEC _before_ the assignment to NAME is performed. This affects
the result of array assignments with the A flag. the result of array assignments with the A flag.
${~SPEC} ${~SPEC}
${~~SPEC}
Turn on the GLOB_SUBST option for the evaluation of SPEC; if the Turn on the GLOB_SUBST option for the evaluation of SPEC; if the
`~' is doubled, turn it off. When this option is set, the string `~' is doubled, turn it off. When this option is set, the string
resulting from the expansion will be interpreted as a pattern resulting from the expansion will be interpreted as a pattern
anywhere that is possible, such as in filename expansion and anywhere that is possible, such as in filename expansion and
filename generation and pattern-matching contexts like the right filename generation and pattern-matching contexts like the right
hand side of the `=' and `!=' operators in conditions. hand side of the `=' and `!=' operators in conditions.
In nested substitutions, note that the effect of the ~ applies to In nested substitutions, note that the effect of the ~ applies to
the result of the current level of substitution. A surrounding the result of the current level of substitution. A surrounding
pattern operation on the result may cancel it. Hence, for pattern operation on the result may cancel it. Hence, for
skipping to change at line 4280 skipping to change at line 4307
-------------------------------- --------------------------------
If the opening brace is directly followed by an opening parenthesis, If the opening brace is directly followed by an opening parenthesis,
the string up to the matching closing parenthesis will be taken as a the string up to the matching closing parenthesis will be taken as a
list of flags. In cases where repeating a flag is meaningful, the list of flags. In cases where repeating a flag is meaningful, the
repetitions need not be consecutive; for example, `(q%q%q)' means the repetitions need not be consecutive; for example, `(q%q%q)' means the
same thing as the more readable `(%%qqq)'. The following flags are same thing as the more readable `(%%qqq)'. The following flags are
supported: supported:
# #
Evaluate the resulting words as numeric expressions and output the Evaluate the resulting words as numeric expressions and interpret
characters corresponding to the resulting integer. Note that this these as character codes. Output the corresponding characters.
form is entirely distinct from use of the # without parentheses. Note that this form is entirely distinct from use of the # without
parentheses.
If the MULTIBYTE option is set and the number is greater than 127 If the MULTIBYTE option is set and the number is greater than 127
(i.e. not an ASCII character) it is treated as a Unicode character. (i.e. not an ASCII character) it is treated as a Unicode character.
% %
Expand all % escapes in the resulting words in the same way as in Expand all % escapes in the resulting words in the same way as in
prompts (see *Note Prompt Expansion::). If this flag is given prompts (see *Note Prompt Expansion::). If this flag is given
twice, full prompt expansion is done on the resulting words, twice, full prompt expansion is done on the resulting words,
depending on the setting of the PROMPT_PERCENT, PROMPT_SUBST and depending on the setting of the PROMPT_PERCENT, PROMPT_SUBST and
PROMPT_BANG options. PROMPT_BANG options.
skipping to change at line 4407 skipping to change at line 4435
this flag may not be combined with subscript ranges. With the this flag may not be combined with subscript ranges. With the
KSH_ARRAYS option a subscript `[*]' or `[@]' is needed to operate KSH_ARRAYS option a subscript `[*]' or `[@]' is needed to operate
on the whole array, as usual. on the whole array, as usual.
L L
Convert all letters in the result to lower case. Convert all letters in the result to lower case.
n n
Sort decimal integers numerically; if the first differing Sort decimal integers numerically; if the first differing
characters of two test strings are not digits, sorting is lexical. characters of two test strings are not digits, sorting is lexical.
Integers with more initial zeroes are sorted before those with `+' and `-' are not treated specially; they are treated as any
fewer or none. Hence the array `foo1 foo02 foo2 foo3 foo20 foo23' other non-digit. Integers with more initial zeroes are sorted
is sorted into the order shown. May be combined with `i' or `O'. before those with fewer or none. Hence the array `foo+24 foo1
foo02 foo2 foo3 foo20 foo23' is sorted into the order shown. May
be combined with `i' or `O'.
-
As n, but a leading minus sign indicates a negative decimal
integer. A leading minus sign not followed by an integer does not
trigger numeric sorting. Note that `+' signs are not handled
specially (this may change in the future).
o o
Sort the resulting words in ascending order; if this appears on its Sort the resulting words in ascending order; if this appears on its
own the sorting is lexical and case-sensitive (unless the locale own the sorting is lexical and case-sensitive (unless the locale
renders it case-insensitive). Sorting in ascending order is the renders it case-insensitive). Sorting in ascending order is the
default for other forms of sorting, so this is ignored if combined default for other forms of sorting, so this is ignored if combined
with `a', `i' or `n'. with `a', `i', `n' or `-'.
O O
Sort the resulting words in descending order; `O' without `a', `i' Sort the resulting words in descending order; `O' without `a',
or `n' sorts in reverse lexical order. May be combined with `a', `i', `n' or `-' sorts in reverse lexical order. May be combined
`i' or `n' to reverse the order of sorting. with `a', `i', `n' or `-' to reverse the order of sorting.
P P
This forces the value of the parameter NAME to be interpreted as a This forces the value of the parameter NAME to be interpreted as a
further parameter name, whose value will be used where appropriate. further parameter name, whose value will be used where appropriate.
Note that flags set with one of the typeset family of commands (in Note that flags set with one of the typeset family of commands (in
particular case transformations) are not applied to the value of particular case transformations) are not applied to the value of
NAME used in this fashion. NAME used in this fashion.
If used with a nested parameter or command substitution, the If used with a nested parameter or command substitution, the
result of that will be taken as a parameter name in the same way. result of that will be taken as a parameter name in the same way.
skipping to change at line 4505 skipping to change at line 4541
upper upper
for parameters whose value is converted to all upper case for parameters whose value is converted to all upper case
when it is expanded when it is expanded
readonly readonly
for readonly parameters for readonly parameters
tag tag
for tagged parameters for tagged parameters
tied
for parameters tied to another parameter in the manner of PATH
(colon-separated list) and path (array), whether these are
special parameters or user-defined with `typeset -T'
export export
for exported parameters for exported parameters
unique unique
for arrays which keep only the first occurrence of duplicated for arrays which keep only the first occurrence of duplicated
values values
hide hide
for parameters with the `hide' flag for parameters with the `hide' flag
skipping to change at line 4686 skipping to change at line 4727
line="one::three" line="one::three"
print -l "${(s.:.)line}" print -l "${(s.:.)line}"
produces two lines of output for one and three and elides the produces two lines of output for one and three and elides the
empty field. To override this behaviour, supply the `(@)' flag as empty field. To override this behaviour, supply the `(@)' flag as
well, i.e. "${(@s.:.)line}". well, i.e. "${(@s.:.)line}".
Z:OPTS: Z:OPTS:
As z but takes a combination of option letters between a following As z but takes a combination of option letters between a following
pair of delimiter characters. With no options the effect is pair of delimiter characters. With no options the effect is
identical to z. (Z+c+) causes comments to be parsed as a string identical to z. The following options are available:
and retained; any field in the resulting array beginning with an
unquoted comment character is a comment. (Z+C+) causes comments (Z+c+)
to be parsed and removed. The rule for comments is standard: causes comments to be parsed as a string and retained; any
anything between a word starting with the third character of field in the resulting array beginning with an unquoted
$HISTCHARS, default #, up to the next newline is a comment. comment character is a comment.
(Z+n+) causes unquoted newlines to be treated as ordinary
whitespace, else they are treated as if they are shell code (Z+C+)
delimiters and converted to semicolons. Options are combined causes comments to be parsed and removed. The rule for
within the same set of delimiters, e.g. (Z+Cn+). comments is standard: anything between a word starting with
the third character of $HISTCHARS, default #, up to the next
newline is a comment.
(Z+n+)
causes unquoted newlines to be treated as ordinary
whitespace, else they are treated as if they are shell code
delimiters and converted to semicolons.
Options are combined within the same set of delimiters, e.g.
(Z+Cn+).
_:FLAGS: _:FLAGS:
The underscore (_) flag is reserved for future use. As of this The underscore (_) flag is reserved for future use. As of this
revision of zsh, there are no valid FLAGS; anything following an revision of zsh, there are no valid FLAGS; anything following an
underscore, other than an empty pair of delimiters, is treated as underscore, other than an empty pair of delimiters, is treated as
an error, and the flag itself has no effect. an error, and the flag itself has no effect.
The following flags are meaningful with the ${...#...} or ${...%...} The following flags are meaningful with the ${...#...} or ${...%...}
forms. The S and I flags may also be used with the ${.../...} forms. forms. The S, I, and * flags may also be used with the ${.../...}
forms.
S S
With # or ##, search for the match that starts closest to the With # or ##, search for the match that starts closest to the
start of the string (a `substring match'). Of all matches at a start of the string (a `substring match'). Of all matches at a
particular position, # selects the shortest and ## the longest: particular position, # selects the shortest and ## the longest:
% str="aXbXc" % str="aXbXc"
% echo ${(S)str#X*} % echo ${(S)str#X*}
abXc abXc
% echo ${(S)str##X*} % echo ${(S)str##X*}
skipping to change at line 4768 skipping to change at line 4820
which switch is the right switch for Ipswich? which switch is the right switch for Ipswich?
substitutions of the form ${(SI:N:)string#w*ch} as N increases substitutions of the form ${(SI:N:)string#w*ch} as N increases
from 1 will match and remove `which', `witch', `witch' and `wich'; from 1 will match and remove `which', `witch', `witch' and `wich';
the form using `##' will match and remove `which switch is the the form using `##' will match and remove `which switch is the
right switch for Ipswich', `witch is the right switch for right switch for Ipswich', `witch is the right switch for
Ipswich', `witch for Ipswich' and `wich'. The form using `%' will Ipswich', `witch for Ipswich' and `wich'. The form using `%' will
remove the same matches as for `#', but in reverse order, and the remove the same matches as for `#', but in reverse order, and the
form using `%%' will remove the same matches as for `##' in reverse form using `%%' will remove the same matches as for `##' in reverse
order. order.
*
Enable EXTENDED_GLOB for substitution via ${.../...} or
${...//...}. Note that `**' does not disable extendedglob.
B B
Include the index of the beginning of the match in the result. Include the index of the beginning of the match in the result.
E E
Include the index one character past the end of the match in the Include the index one character past the end of the match in the
result (note this is inconsistent with other uses of parameter result (note this is inconsistent with other uses of parameter
index). index).
M M
Include the matched portion in the result. Include the matched portion in the result.
skipping to change at line 5148 skipping to change at line 5204
A `~' followed by a number is replaced by the directory at that A `~' followed by a number is replaced by the directory at that
position in the directory stack. `~0' is equivalent to `~+', and `~1' position in the directory stack. `~0' is equivalent to `~+', and `~1'
is the top of the stack. `~+' followed by a number is replaced by the is the top of the stack. `~+' followed by a number is replaced by the
directory at that position in the directory stack. `~+0' is equivalent directory at that position in the directory stack. `~+0' is equivalent
to `~+', and `~+1' is the top of the stack. `~-' followed by a number to `~+', and `~+1' is the top of the stack. `~-' followed by a number
is replaced by the directory that many positions from the bottom of the is replaced by the directory that many positions from the bottom of the
stack. `~-0' is the bottom of the stack. The PUSHD_MINUS option stack. `~-0' is the bottom of the stack. The PUSHD_MINUS option
exchanges the effects of `~+' and `~-' where they are followed by a exchanges the effects of `~+' and `~-' where they are followed by a
number. number.
* Menu:
* Dynamic named directories::
* Static named directories::
* `=' expansion::
* Notes::

File: zsh.info, Node: Dynamic named directories, Next: Static named directorie
s, Up: Filename Expansion
14.7.1 Dynamic named directories 14.7.1 Dynamic named directories
-------------------------------- --------------------------------
If the function zsh_directory_name exists, or the shell variable If the function zsh_directory_name exists, or the shell variable
zsh_directory_name_functions exists and contains an array of function zsh_directory_name_functions exists and contains an array of function
names, then the functions are used to implement dynamic directory names, then the functions are used to implement dynamic directory
naming. The functions are tried in order until one returns status naming. The functions are tried in order until one returns status
zero, so it is important that functions test whether they can handle zero, so it is important that functions test whether they can handle
the case in question and return an appropriate status. the case in question and return an appropriate status.
skipping to change at line 5236 skipping to change at line 5302
dirs=(/home/pws/perforce/*(/:t)) dirs=(/home/pws/perforce/*(/:t))
dirs=(p:${^dirs}) dirs=(p:${^dirs})
_wanted dynamic-dirs expl 'dynamic directory' compadd -S\] -a dirs _wanted dynamic-dirs expl 'dynamic directory' compadd -S\] -a dirs
return return
else else
return 1 return 1
fi fi
return 0 return 0
} }

File: zsh.info, Node: Static named directories, Next: `=' expansion, Prev: Dy
namic named directories, Up: Filename Expansion
14.7.2 Static named directories 14.7.2 Static named directories
------------------------------- -------------------------------
A `~' followed by anything not already covered consisting of any number A `~' followed by anything not already covered consisting of any number
of alphanumeric characters or underscore (`_'), hyphen (`-'), or dot of alphanumeric characters or underscore (`_'), hyphen (`-'), or dot
(`.') is looked up as a named directory, and replaced by the value of (`.') is looked up as a named directory, and replaced by the value of
that named directory if found. Named directories are typically home that named directory if found. Named directories are typically home
directories for users on the system. They may also be defined if the directories for users on the system. They may also be defined if the
text after the `~' is the name of a string shell parameter whose value text after the `~' is the name of a string shell parameter whose value
begins with a `/'. Note that trailing slashes will be removed from the begins with a `/'. Note that trailing slashes will be removed from the
skipping to change at line 5260 skipping to change at line 5329
When the shell prints a path (e.g. when expanding %~ in prompts or when When the shell prints a path (e.g. when expanding %~ in prompts or when
printing the directory stack), the path is checked to see if it has a printing the directory stack), the path is checked to see if it has a
named directory as its prefix. If so, then the prefix portion is named directory as its prefix. If so, then the prefix portion is
replaced with a `~' followed by the name of the directory. The shorter replaced with a `~' followed by the name of the directory. The shorter
of the two ways of referring to the directory is used, i.e. either the of the two ways of referring to the directory is used, i.e. either the
directory name or the full path; the name is used if they are the same directory name or the full path; the name is used if they are the same
length. The parameters $PWD and $OLDPWD are never abbreviated in this length. The parameters $PWD and $OLDPWD are never abbreviated in this
fashion. fashion.

File: zsh.info, Node: `=' expansion, Next: Notes, Prev: Static named director
ies, Up: Filename Expansion
14.7.3 `=' expansion 14.7.3 `=' expansion
-------------------- --------------------
If a word begins with an unquoted `=' and the EQUALS option is set, the If a word begins with an unquoted `=' and the EQUALS option is set, the
remainder of the word is taken as the name of a command. If a command remainder of the word is taken as the name of a command. If a command
exists by that name, the word is replaced by the full pathname of the exists by that name, the word is replaced by the full pathname of the
command. command.

File: zsh.info, Node: Notes, Prev: `=' expansion, Up: Filename Expansion
14.7.4 Notes 14.7.4 Notes
------------ ------------
Filename expansion is performed on the right hand side of a parameter Filename expansion is performed on the right hand side of a parameter
assignment, including those appearing after commands of the typeset assignment, including those appearing after commands of the typeset
family. In this case, the right hand side will be treated as a family. In this case, the right hand side will be treated as a
colon-separated list in the manner of the PATH parameter, so that a `~' colon-separated list in the manner of the PATH parameter, so that a `~'
or an `=' following a `:' is eligible for expansion. All such or an `=' following a `:' is eligible for expansion. All such
behaviour can be disabled by quoting the `~', the `=', or the whole behaviour can be disabled by quoting the `~', the `=', or the whole
expression (but not simply the colon); the EQUALS option is also expression (but not simply the colon); the EQUALS option is also
skipping to change at line 5326 skipping to change at line 5401
Matches any character. Matches any character.
[...] [...]
Matches any of the enclosed characters. Ranges of characters can Matches any of the enclosed characters. Ranges of characters can
be specified by separating two characters by a `-'. A `-' or `]' be specified by separating two characters by a `-'. A `-' or `]'
may be matched by including it as the first character in the list. There may be matched by including it as the first character in the list. There
are also several named classes of characters, in the form are also several named classes of characters, in the form
`[:NAME:]' with the following meanings. The first set use the `[:NAME:]' with the following meanings. The first set use the
macros provided by the operating system to test for the given macros provided by the operating system to test for the given
character combinations, including any modifications due to local character combinations, including any modifications due to local
language settings, see man page ctype(3): language settings, see ctype(3):
[:alnum:] [:alnum:]
The character is alphanumeric The character is alphanumeric
[:alpha:] [:alpha:]
The character is alphabetic The character is alphabetic
[:ascii:] [:ascii:]
The character is 7-bit, i.e. is a single-byte character The character is 7-bit, i.e. is a single-byte character
without the top bit set. without the top bit set.
skipping to change at line 5374 skipping to change at line 5449
The character is an uppercase letter The character is an uppercase letter
[:xdigit:] [:xdigit:]
The character is a hexadecimal digit The character is a hexadecimal digit
Another set of named classes is handled internally by the shell and Another set of named classes is handled internally by the shell and
is not sensitive to the locale: is not sensitive to the locale:
[:IDENT:] [:IDENT:]
The character is allowed to form part of a shell identifier, The character is allowed to form part of a shell identifier,
such as a parameter name such as a parameter name; this test respects the
POSIX_IDENTIFIERS option
[:IFS:] [:IFS:]
The character is used as an input field separator, i.e. is The character is used as an input field separator, i.e. is
contained in the IFS parameter contained in the IFS parameter
[:IFSSPACE:] [:IFSSPACE:]
The character is an IFS white space character; see the The character is an IFS white space character; see the
documentation for IFS in *Note Parameters Used By The Shell::. documentation for IFS in *Note Parameters Used By The Shell::.
[:INCOMPLETE:] [:INCOMPLETE:]
skipping to change at line 6053 skipping to change at line 6129
matches files from 1 byte up to 1 Megabyte inclusive. Note also matches files from 1 byte up to 1 Megabyte inclusive. Note also
that the set of files "less than" the test size only includes that the set of files "less than" the test size only includes
files that would not match the equality test; hence `*(Lm-1)' only files that would not match the equality test; hence `*(Lm-1)' only
matches files of zero size. matches files of zero size.
^ ^
negates all qualifiers following it negates all qualifiers following it
- -
toggles between making the qualifiers work on symbolic links (the toggles between making the qualifiers work on symbolic links (the
default) and the files they point to default) and the files they point to, if any; any symbolic link for
whose target the `stat' system call fails (whatever the cause of
the failure) is treated as a file in its own right
M M
sets the MARK_DIRS option for the current pattern sets the MARK_DIRS option for the current pattern
T T
appends a trailing qualifier mark to the filenames, analogous to appends a trailing qualifier mark to the filenames, analogous to
the LIST_TYPES option, for the current pattern (overrides M) the LIST_TYPES option, for the current pattern (overrides M)
N N
sets the NULL_GLOB option for the current pattern sets the NULL_GLOB option for the current pattern
skipping to change at line 6079 skipping to change at line 6157
sets the NUMERIC_GLOB_SORT option for the current pattern sets the NUMERIC_GLOB_SORT option for the current pattern
YN YN
enables short-circuit mode: the pattern will expand to at most N enables short-circuit mode: the pattern will expand to at most N
filenames. If more than N matches exist, only the first N matches filenames. If more than N matches exist, only the first N matches
in directory traversal order will be considered. in directory traversal order will be considered.
Implies oN when no oC qualifier is used. Implies oN when no oC qualifier is used.
oC oC
specifies how the names of the files should be sorted. If C is n specifies how the names of the files should be sorted. The
they are sorted by name; if it is L they are sorted depending on following values of C sort in the following ways:
the size (length) of the files; if l they are sorted by the number
of links; if a, m, or c they are sorted by the time of the last n
access, modification, or inode change respectively; if d, files in By name.
subdirectories appear before those in the current directory at
each level of the search -- this is best combined with other L
criteria, for example `odon' to sort on names for files within the By the size (length) of the files.
same directory; if N, no sorting is performed. Note that a, m,
and c compare the age against the current time, hence the first l
name in the list is the youngest file. Also note that the By number of links.
modifiers ^ and - are used, so `*(^-oL)' gives a list of all files
sorted by file size in descending order, following any symbolic a
links. Unless oN is used, multiple order specifiers may occur to By time of last access, youngest first.
resolve ties.
m
By time of last modification, youngest first.
c
By time of last inode change, youngest first.
d
By directories: files in subdirectories appear before those
in the current directory at each level of the search -- this
is best combined with other criteria, for example `odon' to
sort on names for files within the same directory.
N
No sorting is performed.
eSTRING
+CMD
Sort by shell code (see below).
Note that the modifiers ^ and - are used, so `*(^-oL)' gives a
list of all files sorted by file size in descending order,
following any symbolic links. Unless oN is used, multiple order
specifiers may occur to resolve ties.
The default sorting is n (by name) unless the Y glob qualifier is The default sorting is n (by name) unless the Y glob qualifier is
used, in which case it is N (unsorted). used, in which case it is N (unsorted).
oe and o+ are special cases; they are each followed by shell code, oe and o+ are special cases; they are each followed by shell code,
delimited as for the e glob qualifier and the + glob qualifier delimited as for the e glob qualifier and the + glob qualifier
respectively (see above). The code is executed for each matched respectively (see above). The code is executed for each matched
file with the parameter REPLY set to the name of the file on entry file with the parameter REPLY set to the name of the file on entry
and globsort appended to zsh_eval_context. The code should modify and globsort appended to zsh_eval_context. The code should modify
the parameter REPLY in some fashion. On return, the value of the the parameter REPLY in some fashion. On return, the value of the
parameter is used instead of the file name as the string on which parameter is used instead of the file name as the string on which
to sort. Unlike other sort operators, oe and o+ may be repeated, to sort. Unlike other sort operators, oe and o+ may be repeated,
but note that the maximum number of sort operators of any kind but note that the maximum number of sort operators of any kind
that may appear in any glob expression is 12. that may appear in any glob expression is 12.
OC OC
like `o', but sorts in descending order; i.e. `*(^oc)' is the same like `o', but sorts in descending order; i.e. `*(^oC)' is the same
as `*(Oc)' and `*(^Oc)' is the same as `*(oc)'; `Od' puts files in as `*(OC)' and `*(^OC)' is the same as `*(oC)'; `Od' puts files in
the current directory before those in subdirectories at each level the current directory before those in subdirectories at each level
of the search. of the search.
[BEG[,END]] [BEG[,END]]
specifies which of the matched filenames should be included in the specifies which of the matched filenames should be included in the
returned list. The syntax is the same as for array subscripts. BEG returned list. The syntax is the same as for array subscripts. BEG
and the optional END may be mathematical expressions. As in and the optional END may be mathematical expressions. As in
parameter subscripting they may be negative to make them count parameter subscripting they may be negative to make them count
from the last match backward. E.g.: `*(-OL[1,3])' gives a list of from the last match backward. E.g.: `*(-OL[1,3])' gives a list of
the names of the three largest files. the names of the three largest files.
skipping to change at line 6294 skipping to change at line 6395
In the third form, KEY is an expression that will be evaluated in In the third form, KEY is an expression that will be evaluated in
arithmetic context (in its simplest form, an integer) that gives the arithmetic context (in its simplest form, an integer) that gives the
index of the element to be assigned with VALUE. In this form any index of the element to be assigned with VALUE. In this form any
elements not explicitly mentioned that come before the largest index to elements not explicitly mentioned that come before the largest index to
which a value is assigned are assigned an empty string. The indices which a value is assigned are assigned an empty string. The indices
may be in any order. Note that this syntax is strict: [ and ]= must may be in any order. Note that this syntax is strict: [ and ]= must
not be quoted, and KEY may not consist of the unquoted string ]=, but not be quoted, and KEY may not consist of the unquoted string ]=, but
is otherwise treated as a simple string. The enhanced forms of is otherwise treated as a simple string. The enhanced forms of
subscript expression that may be used when directly subscripting a subscript expression that may be used when directly subscripting a
variable name, described in the section Array Subscripts below, are not variable name, described in the section `Array Subscripts' below, are
available. not available.
The syntaxes with and without the explicit key may be mixed. An The syntaxes with and without the explicit key may be mixed. An
implicit KEY is deduced by incrementing the index from the previously implicit KEY is deduced by incrementing the index from the previously
assigned element. Note that it is not treated as an error if latter assigned element. Note that it is not treated as an error if latter
assignments in this form overwrite earlier assignments. assignments in this form overwrite earlier assignments.
For example, assuming the option KSH_ARRAYS is not set, the following: For example, assuming the option KSH_ARRAYS is not set, the following:
array=(one [3]=three four) array=(one [3]=three four)
skipping to change at line 6574 skipping to change at line 6675
i i
Like `r', but gives the index of the match instead; this may not be Like `r', but gives the index of the match instead; this may not be
combined with a second argument. On the left side of an combined with a second argument. On the left side of an
assignment, behaves like `r'. For associative arrays, the key assignment, behaves like `r'. For associative arrays, the key
part of each pair is compared to the pattern, and the first part of each pair is compared to the pattern, and the first
matching key found is the result. On failure substitutes the matching key found is the result. On failure substitutes the
length of the array plus one, as discussed under the description length of the array plus one, as discussed under the description
of `r', or the empty string for an associative array. of `r', or the empty string for an associative array.
Note: Although `i' may be applied to a scalar substitution to find
the offset of a substring, the results are likely to be misleading
when searching within substitutions that yield an empty string, or
when searching for the empty substring.
I I
Like `i', but gives the index of the last match, or all possible Like `i', but gives the index of the last match, or all possible
matching keys in an associative array. On failure substitutes 0, matching keys in an associative array. On failure substitutes 0,
or the empty string for an associative array. This flag is best or the empty string for an associative array. This flag is best
when testing for values or keys that do not exist. when testing for values or keys that do not exist.
Note: If the option KSH_ARRAYS is in effect and no match is found,
the result is indistinguishable from the case when the first
element of the array matches.
k k
If used in a subscript on an associative array, this flag causes If used in a subscript on an associative array, this flag causes
the keys to be interpreted as patterns, and returns the value for the keys to be interpreted as patterns, and returns the value for
the first key found where EXP is matched by the key. Note this the first key found where EXP is matched by the key. Note this
could be any such key as no ordering of associative arrays is could be any such key as no ordering of associative arrays is
defined. This flag does not work on the left side of an defined. This flag does not work on the left side of an
assignment to an associative array element. If used on another assignment to an associative array element. If used on another
type of parameter, this behaves like `r'. type of parameter, this behaves like `r'.
K K
skipping to change at line 6801 skipping to change at line 6911
 
File: zsh.info, Node: Parameters Set By The Shell, Next: Parameters Used By Th e Shell, Prev: Local Parameters, Up: Parameters File: zsh.info, Node: Parameters Set By The Shell, Next: Parameters Used By Th e Shell, Prev: Local Parameters, Up: Parameters
15.5 Parameters Set By The Shell 15.5 Parameters Set By The Shell
================================ ================================
In the parameter lists that follow, the mark `<S>' indicates that the In the parameter lists that follow, the mark `<S>' indicates that the
parameter is special. `<Z>' indicates that the parameter does not exist parameter is special. `<Z>' indicates that the parameter does not exist
when the shell initializes in sh or ksh emulation mode. when the shell initializes in sh or ksh emulation mode.
The parameters `!', `#', `*', `-', `?', `@', `$', `ARGC', `HISTCMD',
`LINENO', `PPID', `status', `TTYIDLE', `zsh_eval_context',
`ZSH_EVAL_CONTEXT', and `ZSH_SUBSHELL' are read-only and thus cannot be
restored by the user, so they are not output by `typeset -p'. This
also applies to many read-only parameters loaded from modules.
The following parameters are automatically set by the shell: The following parameters are automatically set by the shell:
! <S> ! <S>
The process ID of the last command started in the background with The process ID of the last command started in the background with
&, put into the background with the bg builtin, or spawned with &, put into the background with the bg builtin, or spawned with
coproc. coproc.
# <S> # <S>
The number of positional parameters in decimal. Note that some The number of positional parameters in decimal. Note that some
confusion may occur with the syntax $#PARAM which substitutes the confusion may occur with the syntax $#PARAM which substitutes the
length of PARAM. Use ${#} to resolve ambiguities. In particular, length of PARAM. Use ${#} to resolve ambiguities. In particular,
the sequence `$#-...' in an arithmetic expression is interpreted as the sequence `$#-...' in an arithmetic expression is interpreted as
the length of the parameter -, q.v. the length of the parameter -, q.v.
ARGC <S> <Z> ARGC <S> <Z>
Same as #. Same as #.
$ <S> $ <S>
The process ID of this shell. Note that this indicates the The process ID of this shell, set when the shell initializes.
original shell started by invoking zsh; all processes forked from Processes forked from the shell without executing a new program,
the shells without executing a new program, such as subshells such as command substitutions and commands grouped with (...), are
started by (...), substitute the same value. subshells that duplicate the current shell, and thus substitute the
same value for $$ as their parent shell.
- <S> - <S>
Flags supplied to the shell on invocation or by the set or setopt Flags supplied to the shell on invocation or by the set or setopt
commands. commands.
* <S> * <S>
An array containing the positional parameters. An array containing the positional parameters.
argv <S> <Z> argv <S> <Z>
Same as *. Assigning to argv changes the local positional Same as *. Assigning to argv changes the local positional
skipping to change at line 6889 skipping to change at line 7006
The effective user ID of the shell process. If you have sufficient The effective user ID of the shell process. If you have sufficient
privileges, you may change the effective user ID of the shell privileges, you may change the effective user ID of the shell
process by assigning to this parameter. Also (assuming sufficient process by assigning to this parameter. Also (assuming sufficient
privileges), you may start a single command with a different privileges), you may start a single command with a different
effective user ID by `(EUID=UID; command)' effective user ID by `(EUID=UID; command)'
If this is made local, it is not implicitly set to 0, but may be If this is made local, it is not implicitly set to 0, but may be
explicitly set locally. explicitly set locally.
ERRNO <S> ERRNO <S>
The value of errno (see man page errno(3)) as set by the most The value of errno (see errno(3)) as set by the most recently
recently failed system call. This value is system dependent and failed system call. This value is system dependent and is
is intended for debugging purposes. It is also useful with the intended for debugging purposes. It is also useful with the
zsh/system module which allows the number to be turned into a name zsh/system module which allows the number to be turned into a name
or message. or message.
To use this parameter, it must first be assigned a value (typically
0 (zero)). It is initially unset for scripting compatibility.
FUNCNEST <S> FUNCNEST <S>
Integer. If greater than or equal to zero, the maximum nesting Integer. If greater than or equal to zero, the maximum nesting
depth of shell functions. When it is exceeded, an error is raised depth of shell functions. When it is exceeded, an error is raised
at the point where a function is called. The default value is at the point where a function is called. The default value is
determined when the shell is configured, but is typically 500. determined when the shell is configured, but is typically 500.
Increasing the value increases the danger of a runaway function Increasing the value increases the danger of a runaway function
recursion causing the shell to crash. Setting a negative value recursion causing the shell to crash. Setting a negative value
turns off the check. turns off the check.
GID <S> GID <S>
skipping to change at line 6936 skipping to change at line 7056
started most recently. Note that in the case of shell functions started most recently. Note that in the case of shell functions
the line number refers to the function as it appeared in the the line number refers to the function as it appeared in the
original definition, not necessarily as displayed by the functions original definition, not necessarily as displayed by the functions
builtin. builtin.
LOGNAME LOGNAME
If the corresponding variable is not set in the environment of the If the corresponding variable is not set in the environment of the
shell, it is initialized to the login name corresponding to the shell, it is initialized to the login name corresponding to the
current login session. This parameter is exported by default but current login session. This parameter is exported by default but
this can be disabled using the typeset builtin. The value is set this can be disabled using the typeset builtin. The value is set
to the string returned by the man page getlogin(3) system call if to the string returned by the getlogin(3) system call if that is
that is available. available.
MACHTYPE MACHTYPE
The machine type (microprocessor class or machine model), as The machine type (microprocessor class or machine model), as
determined at compile time. determined at compile time.
OLDPWD OLDPWD
The previous working directory. This is set when the shell The previous working directory. This is set when the shell
initializes and whenever the directory changes. initializes and whenever the directory changes.
OPTARG <S> OPTARG <S>
skipping to change at line 6959 skipping to change at line 7079
command. command.
OPTIND <S> OPTIND <S>
The index of the last option argument processed by the getopts The index of the last option argument processed by the getopts
command. command.
OSTYPE OSTYPE
The operating system, as determined at compile time. The operating system, as determined at compile time.
PPID <S> PPID <S>
The process ID of the parent of the shell. As for $$, the value The process ID of the parent of the shell, set when the shell
indicates the parent of the original shell and does not change in initializes. As with $$, the value does not change in subshells
subshells. created as a duplicate of the current shell.
PWD PWD
The present working directory. This is set when the shell The present working directory. This is set when the shell
initializes and whenever the directory changes. initializes and whenever the directory changes.
RANDOM <S> RANDOM <S>
A pseudo-random integer from 0 to 32767, newly generated each time A pseudo-random integer from 0 to 32767, newly generated each time
this parameter is referenced. The random number generator can be this parameter is referenced. The random number generator can be
seeded by assigning a numeric value to RANDOM. seeded by assigning a numeric value to RANDOM.
skipping to change at line 6984 skipping to change at line 7104
pseudo-random values unless the value of RANDOM is referenced or pseudo-random values unless the value of RANDOM is referenced or
seeded in the parent shell in between subshell invocations. seeded in the parent shell in between subshell invocations.
SECONDS <S> SECONDS <S>
The number of seconds since shell invocation. If this parameter The number of seconds since shell invocation. If this parameter
is assigned a value, then the value returned upon reference will is assigned a value, then the value returned upon reference will
be the value that was assigned plus the number of seconds since be the value that was assigned plus the number of seconds since
the assignment. the assignment.
Unlike other special parameters, the type of the SECONDS parameter Unlike other special parameters, the type of the SECONDS parameter
can be changed using the typeset command. Only integer and one of can be changed using the typeset command. The type may be changed
the floating point types are allowed. For example, `typeset -F only to one of the floating point types or back to integer. For
SECONDS' causes the value to be reported as a floating point example, `typeset -F SECONDS' causes the value to be reported as a
number. The value is available to microsecond accuracy, although floating point number. The value is available to microsecond
the shell may show more or fewer digits depending on the use of accuracy, although the shell may show more or fewer digits
typeset. See the documentation for the builtin typeset in *Note depending on the use of typeset. See the documentation for the
Shell Builtin Commands:: for more details. builtin typeset in *Note Shell Builtin Commands:: for more details.
SHLVL <S> SHLVL <S>
Incremented by one each time a new shell is started. Incremented by one each time a new shell is started.
signals signals
An array containing the names of the signals. Note that with the An array containing the names of the signals. Note that with the
standard zsh numbering of array indices, where the first element standard zsh numbering of array indices, where the first element
has index 1, the signals are offset by 1 from the signal number has index 1, the signals are offset by 1 from the signal number
used by the operating system. For example, on typical Unix-like used by the operating system. For example, on typical Unix-like
systems HUP is signal number 1, but is referred to as $signals[2]. systems HUP is signal number 1, but is referred to as $signals[2].
 End of changes. 68 change blocks. 
150 lines changed or deleted 273 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)