{
    "content": [
        {
            "type": "text",
            "text": "# zshmisc (info)\n\n## NAME\n\nzshmisc - everything and then some  SIMPLE COMMANDS & PIPELINES A  simple  command is a sequence of optional parameter assignments fol- lowed by  blank-separated  words,  with  optional  redirections  inter- spersed.   For  a  description of assignment, see the beginning of zsh- param(1).  The first word is the command to be executed, and the remaining  words, if  any, are arguments to the command.  If a command name is given, the parameter assignments modify the environment of the command when it  is executed.   The  value  of  a simple command is its exit status, or 128 plus the signal number if terminated by a signal.  For example,  echo foo  is a simple command with arguments.  A pipeline is either a simple command, or a sequence  of  two  or  more simple commands where each command is separated from the next by `|' or `|&'.  Where commands are separated by `|', the standard output of  the first  command is connected to the standard input of the next.  `|&' is shorthand for `2>&1 |', which connects both the standard output and the standard  error  of the command to the standard input of the next.  The value of a pipeline is the value of the last command, unless the  pipe- line  is preceded by `!' in which case the value is the logical inverse of the value of the last command.  For example,  echo foo | sed 's/foo/bar/'  is a pipeline, where the output (`foo' plus a  newline)  of  the  first command will be passed to the input of the second.  If a pipeline is preceded by `coproc', it is executed as a coprocess; a two-way pipe is established between it and the parent shell.  The shell can read from or write to the coprocess by means of the `>&p' and `<&p' redirection operators or with `print -p' and  `read  -p'.   A  pipeline cannot be preceded by both `coproc' and `!'.  If job control is active, the coprocess can be treated in other than input and output as an ordi- nary background job.  A  sublist  is  either  a single pipeline, or a sequence of two or more pipelines separated by `&&' or `||'.  If two pipelines are separated by `&&',  the  second pipeline is executed only if the first succeeds (re- turns a zero status).  If two pipelines are separated by `||', the sec- ond  is  executed  only  if the first fails (returns a nonzero status). Both operators have equal precedence and  are  left  associative.   The value  of  the sublist is the value of the last pipeline executed.  For example,  dmesg | grep panic && print yes  is a sublist consisting of two pipelines, the second just a simple com- mand  which  will be executed if and only if the grep command returns a zero status.  If it does not, the value of the sublist is  that  return status,  else  it is the status returned by the print (almost certainly zero).  A list is a sequence of zero or more sublists, in which each sublist is terminated  by `;', `&', `&|', `&!', or a newline.  This terminator may optionally be omitted from the last sublist in the list when  the  list appears as a complex command inside `(...)' or `{...}'.  When a sublist is terminated by `;' or newline, the shell waits for it to  finish  be- fore  executing the next sublist.  If a sublist is terminated by a `&', `&|', or `&!', the shell executes the last pipeline in it in the  back- ground,  and  does  not wait for it to finish (note the difference from other shells which execute the whole sublist  in  the  background).   A backgrounded pipeline returns a status of zero.  More generally, a list can be seen as a set of any shell commands what- soever, including the complex commands below; this is implied  wherever the  word  `list' appears in later descriptions.  For example, the com- mands in a shell function form a special sort of list.\n\n## Sections\n\n- **NAME**\n- **PRECOMMAND MODIFIERS**\n- **COMPLEX COMMANDS**\n- **ALTERNATE FORMS FOR COMPLEX COMMANDS**\n- **RESERVED WORDS**\n- **ERRORS**\n- **COMMENTS**\n- **ALIASING**\n- **QUOTING**\n- **REDIRECTION**\n- **OPENING FILE DESCRIPTORS USING PARAMETERS**\n- **MULTIOS**\n- **REDIRECTIONS WITH NO COMMAND**\n- **COMMAND EXECUTION**\n- **FUNCTIONS**\n- **AUTOLOADING FUNCTIONS**\n- **ANONYMOUS FUNCTIONS**\n- **SPECIAL FUNCTIONS**\n- **JOBS**\n- **SIGNALS**\n- **ARITHMETIC EVALUATION**\n- **CONDITIONAL EXPRESSIONS**\n- **EXPANSION OF PROMPT SEQUENCES**\n- **SIMPLE PROMPT ESCAPES**\n- **CONDITIONAL SUBSTRINGS IN PROMPTS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "zshmisc",
        "section": "",
        "mode": "info",
        "summary": "zshmisc - everything and then some  SIMPLE COMMANDS & PIPELINES A  simple  command is a sequence of optional parameter assignments fol- lowed by  blank-separated  words,  with  optional  redirections  inter- spersed.   For  a  description of assignment, see the beginning of zsh- param(1).  The first word is the command to be executed, and the remaining  words, if  any, are arguments to the command.  If a command name is given, the parameter assignments modify the environment of the command when it  is executed.   The  value  of  a simple command is its exit status, or 128 plus the signal number if terminated by a signal.  For example,  echo foo  is a simple command with arguments.  A pipeline is either a simple command, or a sequence  of  two  or  more simple commands where each command is separated from the next by `|' or `|&'.  Where commands are separated by `|', the standard output of  the first  command is connected to the standard input of the next.  `|&' is shorthand for `2>&1 |', which connects both the standard output and the standard  error  of the command to the standard input of the next.  The value of a pipeline is the value of the last command, unless the  pipe- line  is preceded by `!' in which case the value is the logical inverse of the value of the last command.  For example,  echo foo | sed 's/foo/bar/'  is a pipeline, where the output (`foo' plus a  newline)  of  the  first command will be passed to the input of the second.  If a pipeline is preceded by `coproc', it is executed as a coprocess; a two-way pipe is established between it and the parent shell.  The shell can read from or write to the coprocess by means of the `>&p' and `<&p' redirection operators or with `print -p' and  `read  -p'.   A  pipeline cannot be preceded by both `coproc' and `!'.  If job control is active, the coprocess can be treated in other than input and output as an ordi- nary background job.  A  sublist  is  either  a single pipeline, or a sequence of two or more pipelines separated by `&&' or `||'.  If two pipelines are separated by `&&',  the  second pipeline is executed only if the first succeeds (re- turns a zero status).  If two pipelines are separated by `||', the sec- ond  is  executed  only  if the first fails (returns a nonzero status). Both operators have equal precedence and  are  left  associative.   The value  of  the sublist is the value of the last pipeline executed.  For example,  dmesg | grep panic && print yes  is a sublist consisting of two pipelines, the second just a simple com- mand  which  will be executed if and only if the grep command returns a zero status.  If it does not, the value of the sublist is  that  return status,  else  it is the status returned by the print (almost certainly zero).  A list is a sequence of zero or more sublists, in which each sublist is terminated  by `;', `&', `&|', `&!', or a newline.  This terminator may optionally be omitted from the last sublist in the list when  the  list appears as a complex command inside `(...)' or `{...}'.  When a sublist is terminated by `;' or newline, the shell waits for it to  finish  be- fore  executing the next sublist.  If a sublist is terminated by a `&', `&|', or `&!', the shell executes the last pipeline in it in the  back- ground,  and  does  not wait for it to finish (note the difference from other shells which execute the whole sublist  in  the  background).   A backgrounded pipeline returns a status of zero.  More generally, a list can be seen as a set of any shell commands what- soever, including the complex commands below; this is implied  wherever the  word  `list' appears in later descriptions.  For example, the com- mands in a shell function form a special sort of list.",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 74,
                "subsections": []
            },
            {
                "name": "PRECOMMAND MODIFIERS",
                "lines": 49,
                "subsections": []
            },
            {
                "name": "COMPLEX COMMANDS",
                "lines": 193,
                "subsections": []
            },
            {
                "name": "ALTERNATE FORMS FOR COMPLEX COMMANDS",
                "lines": 67,
                "subsections": []
            },
            {
                "name": "RESERVED WORDS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "ERRORS",
                "lines": 69,
                "subsections": []
            },
            {
                "name": "COMMENTS",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "ALIASING",
                "lines": 100,
                "subsections": []
            },
            {
                "name": "QUOTING",
                "lines": 22,
                "subsections": []
            },
            {
                "name": "REDIRECTION",
                "lines": 134,
                "subsections": []
            },
            {
                "name": "OPENING FILE DESCRIPTORS USING PARAMETERS",
                "lines": 51,
                "subsections": []
            },
            {
                "name": "MULTIOS",
                "lines": 104,
                "subsections": []
            },
            {
                "name": "REDIRECTIONS WITH NO COMMAND",
                "lines": 23,
                "subsections": []
            },
            {
                "name": "COMMAND EXECUTION",
                "lines": 27,
                "subsections": []
            },
            {
                "name": "FUNCTIONS",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "AUTOLOADING FUNCTIONS",
                "lines": 115,
                "subsections": []
            },
            {
                "name": "ANONYMOUS FUNCTIONS",
                "lines": 44,
                "subsections": []
            },
            {
                "name": "SPECIAL FUNCTIONS",
                "lines": 170,
                "subsections": []
            },
            {
                "name": "JOBS",
                "lines": 92,
                "subsections": []
            },
            {
                "name": "SIGNALS",
                "lines": 15,
                "subsections": []
            },
            {
                "name": "ARITHMETIC EVALUATION",
                "lines": 239,
                "subsections": []
            },
            {
                "name": "CONDITIONAL EXPRESSIONS",
                "lines": 237,
                "subsections": []
            },
            {
                "name": "EXPANSION OF PROMPT SEQUENCES",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "SIMPLE PROMPT ESCAPES",
                "lines": 196,
                "subsections": []
            },
            {
                "name": "CONDITIONAL SUBSTRINGS IN PROMPTS",
                "lines": 108,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "zshmisc - everything and then some\n\nSIMPLE COMMANDS & PIPELINES\nA  simple  command is a sequence of optional parameter assignments fol-\nlowed by  blank-separated  words,  with  optional  redirections  inter-\nspersed.   For  a  description of assignment, see the beginning of zsh-\nparam(1).\n\nThe first word is the command to be executed, and the remaining  words,\nif  any, are arguments to the command.  If a command name is given, the\nparameter assignments modify the environment of the command when it  is\nexecuted.   The  value  of  a simple command is its exit status, or 128\nplus the signal number if terminated by a signal.  For example,\n\necho foo\n\nis a simple command with arguments.\n\nA pipeline is either a simple command, or a sequence  of  two  or  more\nsimple commands where each command is separated from the next by `|' or\n`|&'.  Where commands are separated by `|', the standard output of  the\nfirst  command is connected to the standard input of the next.  `|&' is\nshorthand for `2>&1 |', which connects both the standard output and the\nstandard  error  of the command to the standard input of the next.  The\nvalue of a pipeline is the value of the last command, unless the  pipe-\nline  is preceded by `!' in which case the value is the logical inverse\nof the value of the last command.  For example,\n\necho foo | sed 's/foo/bar/'\n\nis a pipeline, where the output (`foo' plus a  newline)  of  the  first\ncommand will be passed to the input of the second.\n\nIf a pipeline is preceded by `coproc', it is executed as a coprocess; a\ntwo-way pipe is established between it and the parent shell.  The shell\ncan read from or write to the coprocess by means of the `>&p' and `<&p'\nredirection operators or with `print -p' and  `read  -p'.   A  pipeline\ncannot be preceded by both `coproc' and `!'.  If job control is active,\nthe coprocess can be treated in other than input and output as an ordi-\nnary background job.\n\nA  sublist  is  either  a single pipeline, or a sequence of two or more\npipelines separated by `&&' or `||'.  If two pipelines are separated by\n`&&',  the  second pipeline is executed only if the first succeeds (re-\nturns a zero status).  If two pipelines are separated by `||', the sec-\nond  is  executed  only  if the first fails (returns a nonzero status).\nBoth operators have equal precedence and  are  left  associative.   The\nvalue  of  the sublist is the value of the last pipeline executed.  For\nexample,\n\ndmesg | grep panic && print yes\n\nis a sublist consisting of two pipelines, the second just a simple com-\nmand  which  will be executed if and only if the grep command returns a\nzero status.  If it does not, the value of the sublist is  that  return\nstatus,  else  it is the status returned by the print (almost certainly\nzero).\n\nA list is a sequence of zero or more sublists, in which each sublist is\nterminated  by `;', `&', `&|', `&!', or a newline.  This terminator may\noptionally be omitted from the last sublist in the list when  the  list\nappears as a complex command inside `(...)' or `{...}'.  When a sublist\nis terminated by `;' or newline, the shell waits for it to  finish  be-\nfore  executing the next sublist.  If a sublist is terminated by a `&',\n`&|', or `&!', the shell executes the last pipeline in it in the  back-\nground,  and  does  not wait for it to finish (note the difference from\nother shells which execute the whole sublist  in  the  background).   A\nbackgrounded pipeline returns a status of zero.\n\nMore generally, a list can be seen as a set of any shell commands what-\nsoever, including the complex commands below; this is implied  wherever\nthe  word  `list' appears in later descriptions.  For example, the com-\nmands in a shell function form a special sort of list.\n",
                "subsections": []
            },
            "PRECOMMAND MODIFIERS": {
                "content": "A simple command may be preceded by a precommand modifier,  which  will\nalter  how  the  command  is  interpreted.   These  modifiers are shell\nbuiltin commands with the exception of nocorrect which  is  a  reserved\nword.\n\n-      The  command  is  executed  with  a `-' prepended to its argv[0]\nstring.\n\nbuiltin\nThe command word is taken to be the name of a  builtin  command,\nrather than a shell function or external command.\n\ncommand [ -pvV ]\nThe command word is taken to be the name of an external command,\nrather than a shell function or builtin.   If the POSIXBUILTINS\noption  is  set, builtins will also be executed but certain spe-\ncial properties of them are suppressed. The -p flag causes a de-\nfault  path to be searched instead of that in $path. With the -v\nflag, command is similar to whence and with -V, it is equivalent\nto whence -v.\n\nexec [ -cl ] [ -a argv0 ]\nThe  following  command  together  with  any arguments is run in\nplace of the current process, rather than as a sub-process.  The\nshell  does not fork and is replaced.  The shell does not invoke\nTRAPEXIT, nor does it source zlogout  files.   The  options  are\nprovided for compatibility with other shells.\n\nThe -c option clears the environment.\n\nThe  -l  option  is  equivalent to the - precommand modifier, to\ntreat the replacement command as a login shell; the  command  is\nexecuted  with  a  - prepended to its argv[0] string.  This flag\nhas no effect if used together with the -a option.\n\nThe -a option is used to specify explicitly the  argv[0]  string\n(the  name  of  the command as seen by the process itself) to be\nused by the replacement command and is  directly  equivalent  to\nsetting a value for the ARGV0 environment variable.\n\nnocorrect\nSpelling  correction is not done on any of the words.  This must\nappear before any other precommand modifier,  as  it  is  inter-\npreted  immediately,  before any parsing is done.  It has no ef-\nfect in non-interactive shells.\n\nnoglob Filename generation (globbing) is not performed on  any  of  the\nwords.\n",
                "subsections": []
            },
            "COMPLEX COMMANDS": {
                "content": "A complex command in zsh is one of the following:\n\nif list then list [ elif list then list ] ... [ else list ] fi\nThe  if  list is executed, and if it returns a zero exit status,\nthe then list is executed.  Otherwise, the elif list is executed\nand  if  its status is zero, the then list is executed.  If each\nelif list returns nonzero status, the else list is executed.\n\nfor name ... [ in word ... ] term do list done\nExpand the list of words, and set the parameter name to each  of\nthem  in  turn,  executing  list each time.  If the `in word' is\nomitted, use the positional parameters instead of the words.\n\nThe term consists of one or more newline or  ;  which  terminate\nthe words, and are optional when the `in word' is omitted.\n\nMore  than  one  parameter  name  can  appear before the list of\nwords.  If N names are given, then on each execution of the loop\nthe  next  N words are assigned to the corresponding parameters.\nIf there are more names than remaining words, the remaining  pa-\nrameters  are  each  set  to the empty string.  Execution of the\nloop ends when there is no remaining word to assign to the first\nname.  It is only possible for in to appear as the first name in\nthe list, else it will be treated as  marking  the  end  of  the\nlist.\n\nfor (( [expr1] ; [expr2] ; [expr3] )) do list done\nThe arithmetic expression expr1 is evaluated first (see the sec-\ntion `Arithmetic Evaluation').  The arithmetic expression  expr2\nis  repeatedly  evaluated  until  it  evaluates to zero and when\nnon-zero, list is executed and the arithmetic  expression  expr3\nevaluated.   If any expression is omitted, then it behaves as if\nit evaluated to 1.\n\nwhile list do list done\nExecute the do list as long as the while  list  returns  a  zero\nexit status.\n\nuntil list do list done\nExecute the do list as long as until list returns a nonzero exit\nstatus.\n\nrepeat word do list done\nword is expanded and treated as an arithmetic expression,  which\nmust evaluate to a number n.  list is then executed n times.\n\nThe  repeat  syntax is disabled by default when the shell starts\nin a mode emulating another shell.  It can be enabled  with  the\ncommand `enable -r repeat'\n\ncase  word  in  [ [(] pattern [ | pattern ] ... ) list (;;|;&|;|) ] ...\nesac\nExecute the list associated with the first pattern that  matches\nword, if any.  The form of the patterns is the same as that used\nfor filename generation.  See the section `Filename Generation'.\n\nNote further that, unless the SHGLOB option is set,  the  whole\npattern  with alternatives is treated by the shell as equivalent\nto a group of patterns within parentheses, although white  space\nmay  appear  about the parentheses and the vertical bar and will\nbe stripped from the pattern at those points.  White  space  may\nappear  elsewhere  in the pattern; this is not stripped.  If the\nSHGLOB option is set, so that an opening parenthesis can be un-\nambiguously  treated  as part of the case syntax, the expression\nis parsed into separate words and these are  treated  as  strict\nalternatives (as in other shells).\n\nIf  the  list that is executed is terminated with ;& rather than\n;;, the following list is also executed.  The rule for the  ter-\nminator of the following list ;;, ;& or ;| is applied unless the\nesac is reached.\n\nIf the list that is executed is terminated  with  ;|  the  shell\ncontinues  to scan the patterns looking for the next match, exe-\ncuting the corresponding list, and applying  the  rule  for  the\ncorresponding  terminator  ;;,  ;& or ;|.  Note that word is not\nre-expanded; all applicable patterns are tested  with  the  same\nword.\n\nselect name [ in word ... term ] do list done\nwhere  term  is one or more newline or ; to terminate the words.\nPrint the set of words, each preceded by a number.   If  the  in\nword  is  omitted,  use  the positional parameters.  The PROMPT3\nprompt is printed and a line is read from the line editor if the\nshell is interactive and that is active, or else standard input.\nIf this line consists of the number of one of the listed  words,\nthen the parameter name is set to the word corresponding to this\nnumber.  If this line is empty, the selection  list  is  printed\nagain.   Otherwise,  the  value  of the parameter name is set to\nnull.  The contents of the line  read  from  standard  input  is\nsaved  in the parameter REPLY.  list is executed for each selec-\ntion until a break or end-of-file is encountered.\n\n( list )\nExecute list in a subshell.  Traps set by the trap  builtin  are\nreset to their default values while executing list.\n\n{ list }\nExecute list.\n\n{ try-list } always { always-list }\nFirst  execute try-list.  Regardless of errors, or break or con-\ntinue commands encountered within try-list, execute always-list.\nExecution  then  continues  from  the result of the execution of\ntry-list; in other words, any error, or break or  continue  com-\nmand  is  treated  in the normal way, as if always-list were not\npresent.  The two chunks of code are referred  to  as  the  `try\nblock' and the `always block'.\n\nOptional  newlines  or  semicolons  may appear after the always;\nnote, however, that they may not appear  between  the  preceding\nclosing brace and the always.\n\nAn `error' in this context is a condition such as a syntax error\nwhich causes the shell to abort execution of the  current  func-\ntion,  script,  or  list.   Syntax  errors encountered while the\nshell is parsing the code do not cause the always-list to be ex-\necuted.   For  example,  an  erroneously constructed if block in\ntry-list would cause the shell to abort during parsing, so  that\nalways-list  would not be executed, while an erroneous substitu-\ntion such as ${*foo*} would cause a run-time error, after  which\nalways-list would be executed.\n\nAn  error condition can be tested and reset with the special in-\nteger variable  TRYBLOCKERROR.   Outside  an  always-list  the\nvalue  is  irrelevant,  but it is initialised to -1.  Inside al-\nways-list, the value is 1 if an error occurred in the  try-list,\nelse  0.  If TRYBLOCKERROR is set to 0 during the always-list,\nthe error condition caused by the try-list is reset,  and  shell\nexecution  continues normally after the end of always-list.  Al-\ntering the value during the try-list is not useful (unless  this\nforms part of an enclosing always block).\n\nRegardless  of TRYBLOCKERROR, after the end of always-list the\nnormal shell status $? is  the  value  returned  from  try-list.\nThis   will   be  non-zero  if  there  was  an  error,  even  if\nTRYBLOCKERROR was set to zero.\n\nThe following executes the given code, ignoring  any  errors  it\ncauses.   This is an alternative to the usual convention of pro-\ntecting code by executing it in a subshell.\n\n{\n# code which may cause an error\n} always {\n# This code is executed regardless of the error.\n(( TRYBLOCKERROR = 0 ))\n}\n# The error condition has been reset.\n\nWhen a try block occurs outside of any function, a return  or  a\nexit encountered in try-list does not cause the execution of al-\nways-list.  Instead, the shell exits immediately after any  EXIT\ntrap has been executed.  Otherwise, a return command encountered\nin try-list will cause the execution of always-list,  just  like\nbreak and continue.\n\nfunction word ... [ () ] [ term ] { list }\nword ... () [ term ] { list }\nword ... () [ term ] command\nwhere term is one or more newline or ;.  Define a function which\nis referenced by any one of word.  Normally, only  one  word  is\nprovided;  multiple  words  are  usually only useful for setting\ntraps.  The body of the function is the list between the  {  and\n}.  See the section `Functions'.\n\nIf  the  option  SHGLOB  is  set  for  compatibility with other\nshells, then whitespace may appear between the  left  and  right\nparentheses  when there is a single word;  otherwise, the paren-\ntheses will be treated as forming a  globbing  pattern  in  that\ncase.\n\nIn  any of the forms above, a redirection may appear outside the\nfunction body, for example\n\nfunc() { ... } 2>&1\n\nThe redirection is stored with the function and applied whenever\nthe  function is executed.  Any variables in the redirection are\nexpanded at the point the function is executed, but outside  the\nfunction scope.\n\ntime [ pipeline ]\nThe  pipeline is executed, and timing statistics are reported on\nthe standard error in the form specified by the TIMEFMT  parame-\nter.   If  pipeline is omitted, print statistics about the shell\nprocess and its children.\n\n[[ exp ]]\nEvaluates the conditional expression exp and return a zero  exit\nstatus if it is true.  See the section `Conditional Expressions'\nfor a description of exp.\n",
                "subsections": []
            },
            "ALTERNATE FORMS FOR COMPLEX COMMANDS": {
                "content": "Many of  zsh's  complex  commands  have  alternate  forms.   These  are\nnon-standard  and  are  likely not to be obvious even to seasoned shell\nprogrammers; they should not be used anywhere that portability of shell\ncode is a concern.\n\nThe short versions below only work if sublist is of the form `{ list }'\nor if the SHORTLOOPS option is set.  For the if, while and until  com-\nmands, in both these cases the test part of the loop must also be suit-\nably delimited, such as by `[[ ... ]]' or `(( ... ))', else the end  of\nthe  test will not be recognized.  For the for, repeat, case and select\ncommands no such special form for the arguments is necessary,  but  the\nother  condition (the special form of sublist or use of the SHORTLOOPS\noption) still applies.\n\nif list { list } [ elif list { list } ] ... [ else { list } ]\nAn alternate form of if.  The rules mean that\n\nif [[ -o ignorebraces ]] {\nprint yes\n}\n\nworks, but\n\nif true {  # Does not work!\nprint yes\n}\n\ndoes not, since the test is not suitably delimited.\n\nif list sublist\nA short form of the alternate if.  The same limitations  on  the\nform of list apply as for the previous form.\n\nfor name ... ( word ... ) sublist\nA short form of for.\n\nfor name ... [ in word ... ] term sublist\nwhere  term is at least one newline or ;.  Another short form of\nfor.\n\nfor (( [expr1] ; [expr2] ; [expr3] )) sublist\nA short form of the arithmetic for command.\n\nforeach name ... ( word ... ) list end\nAnother form of for.\n\nwhile list { list }\nAn alternative form of while.  Note the limitations on the  form\nof list mentioned above.\n\nuntil list { list }\nAn  alternative form of until.  Note the limitations on the form\nof list mentioned above.\n\nrepeat word sublist\nThis is a short form of repeat.\n\ncase word { [ [(] pattern [ | pattern ] ... ) list (;;|;&|;|) ] ... }\nAn alternative form of case.\n\nselect name [ in word ... term ] sublist\nwhere term is at least one newline or ;.  A short  form  of  se-\nlect.\n\nfunction word ... [ () ] [ term ] sublist\nThis is a short form of function.\n",
                "subsections": []
            },
            "RESERVED WORDS": {
                "content": "The  following  words are recognized as reserved words when used as the\nfirst word of a command unless quoted or disabled using disable -r:\n\ndo done esac then elif else fi for case if while function  repeat  time\nuntil select coproc nocorrect foreach end ! [[ { } declare export float\ninteger local readonly typeset\n\nAdditionally, `}' is recognized in any  position  if  neither  the  IG-\nNOREBRACES option nor the IGNORECLOSEBRACES option is set.\n",
                "subsections": []
            },
            "ERRORS": {
                "content": "Certain  errors  are  treated  as fatal by the shell: in an interactive\nshell, they cause control to return to  the  command  line,  and  in  a\nnon-interactive  shell  they  cause  the shell to be aborted.  In older\nversions of zsh, a non-interactive shell running  a  script  would  not\nabort  completely, but would resume execution at the next command to be\nread from the script, skipping the remainder of any functions or  shell\nconstructs  such as loops or conditions; this somewhat illogical behav-\niour can be recovered by setting the option CONTINUEONERROR.\n\nFatal errors found in non-interactive shells include:\n\no      Failure to parse shell options passed when invoking the shell\n\no      Failure to change options with the set builtin\n\no      Parse errors of all sorts, including failures to parse mathemat-\nical expressions\n\no      Failures  to  set or modify variable behaviour with typeset, lo-\ncal, declare, export, integer, float\n\no      Execution of  incorrectly  positioned  loop  control  structures\n(continue, break)\n\no      Attempts  to  use  regular expression with no regular expression\nmodule available\n\no      Disallowed operations when the RESTRICTED options is set\n\no      Failure to create a pipe needed for a pipeline\n\no      Failure to create a multio\n\no      Failure to autoload a module needed for a declared shell feature\n\no      Errors creating command or process substitutions\n\no      Syntax errors in glob qualifiers\n\no      File generation errors where not caught by the  option  BADPAT-\nTERN\n\no      All bad patterns used for matching within case statements\n\no      File generation failures where not caused by NOMATCH or similar\noptions\n\no      All file generation errors where the pattern was used to  create\na multio\n\no      Memory errors where detected by the shell\n\no      Invalid subscripts to shell variables\n\no      Attempts to assign read-only variables\n\no      Logical  errors  with  variables such as assignment to the wrong\ntype\n\no      Use of invalid variable names\n\no      Errors in variable substitution syntax\n\no      Failure to convert characters in $'...' expressions\n\nIf the POSIXBUILTINS option is set, more errors associated with  shell\nbuiltin  commands are treated as fatal, as specified by the POSIX stan-\ndard.\n",
                "subsections": []
            },
            "COMMENTS": {
                "content": "In non-interactive shells, or in interactive shells with  the  INTERAC-\nTIVECOMMENTS  option set, a word beginning with the third character of\nthe histchars parameter (`#' by default) causes that word and  all  the\nfollowing characters up to a newline to be ignored.\n",
                "subsections": []
            },
            "ALIASING": {
                "content": "Every eligible word in the shell input is checked to see if there is an\nalias defined for it.  If so, it is replaced by the text of  the  alias\nif it is in command position (if it could be the first word of a simple\ncommand), or if the alias is global.  If the replacement text ends with\na  space,  the next word in the shell input is always eligible for pur-\nposes of alias expansion.  An alias is defined using the alias builtin;\nglobal aliases may be defined using the -g option to that builtin.\n\nA word is defined as:\n\no      Any plain string or glob pattern\n\no      Any  quoted  string,  using  any  quoting  method (note that the\nquotes must be part of the alias definition for this to be  eli-\ngible)\n\no      Any parameter reference or command substitution\n\no      Any  series of the foregoing, concatenated without whitespace or\nother tokens between them\n\no      Any reserved word (case, do, else, etc.)\n\no      With global aliasing, any command separator, any redirection op-\nerator, and `(' or `)' when not part of a glob pattern\n\nAlias  expansion  is done on the shell input before any other expansion\nexcept history expansion.  Therefore, if an alias is  defined  for  the\nword  foo,  alias expansion may be avoided by quoting part of the word,\ne.g. \\foo.  Any form of quoting works, although  there  is  nothing  to\nprevent  an  alias  being  defined  for the quoted form such as \\foo as\nwell.\n\nWhen POSIXALIASES is set, only plain unquoted strings are eligible for\naliasing.   The  alias  builtin does not reject ineligible aliases, but\nthey are not expanded.\n\nFor use with completion, which would remove an initial  backslash  fol-\nlowed  by  a character that isn't special, it may be more convenient to\nquote the word by starting with a single quote, i.e.  'foo;  completion\nwill automatically add the trailing single quote.\n\nAlias difficulties\nAlthough aliases can be used in ways that bend normal shell syntax, not\nevery string of non-white-space characters can be used as an alias.\n\nAny set of characters not listed as a word above is not a  word,  hence\nno  attempt  is  made to expand it as an alias, no matter how it is de-\nfined (i.e. via the builtin or the special parameter aliases  described\nin the section THE ZSH/PARAMETER MODULE in zshmodules(1)).  However, as\nnoted in the case of POSIXALIASES above, the shell does not attempt to\ndeduce  whether  the string corresponds to a word at the time the alias\nis created.\n\nFor example, an expression containing an = at the start  of  a  command\nline  is  an assignment and cannot be expanded as an alias; a lone = is\nnot an assignment but can only be set as an alias using the  parameter,\nas otherwise the = is taken part of the syntax of the builtin command.\n\nIt  is  not  presently possible to alias the `((' token that introduces\narithmetic expressions, because until a full statement has been parsed,\nit  cannot be distinguished from two consecutive `(' tokens introducing\nnested subshells.  Also, if a separator such  as  &&  is  aliased,  \\&&\nturns into the two tokens \\& and &, each of which may have been aliased\nseparately.  Similarly for \\<<, \\>|, etc.\n\nThere is a commonly encountered problem with aliases illustrated by the\nfollowing code:\n\nalias echobar='echo bar'; echobar\n\nThis  prints  a  message  that  the command echobar could not be found.\nThis happens because aliases are expanded when the code is read in; the\nentire  line  is read in one go, so that when echobar is executed it is\ntoo late to expand the newly defined alias.  This is often a problem in\nshell scripts, functions, and code executed with `source' or `.'.  Con-\nsequently, use of functions  rather  than  aliases  is  recommended  in\nnon-interactive code.\n\nNote  also  the  unhelpful  interaction of aliases and function defini-\ntions:\n\nalias func='noglob func'\nfunc() {\necho Do something with $*\n}\n\nBecause aliases are expanded in function definitions, this  causes  the\nfollowing command to be executed:\n\nnoglob func() {\necho Do something with $*\n}\n\nwhich  defines noglob as well as func as functions with the body given.\nTo avoid this, either quote the name func or use the alternative  func-\ntion  definition  form  `function func'.  Ensuring the alias is defined\nafter the function works but is problematic if the code fragment  might\nbe re-executed.\n",
                "subsections": []
            },
            "QUOTING": {
                "content": "A  character  may be quoted (that is, made to stand for itself) by pre-\nceding it with a `\\'.  `\\' followed by a newline is ignored.\n\nA string enclosed between `$'' and `'' is processed the same way as the\nstring arguments of the print builtin, and the resulting string is con-\nsidered to be entirely quoted.  A literal `'' character can be included\nin the string by using the `\\'' escape.\n\nAll  characters  enclosed  between a pair of single quotes ('') that is\nnot preceded by a `$' are quoted.  A single quote cannot appear  within\nsingle  quotes unless the option RCQUOTES is set, in which case a pair\nof single quotes are turned into a single quote.  For example,\n\nprint ''''\n\noutputs nothing apart from a newline if RCQUOTES is not set,  but  one\nsingle quote if it is set.\n\nInside  double  quotes  (\"\"), parameter and command substitution occur,\nand `\\' quotes the characters `\\', ``', `\"', `$', and the first charac-\nter of $histchars (default `!').\n",
                "subsections": []
            },
            "REDIRECTION": {
                "content": "If  a  command is followed by & and job control is not active, then the\ndefault standard input for the command is  the  empty  file  /dev/null.\nOtherwise,  the environment for the execution of a command contains the\nfile descriptors of the invoking  shell  as  modified  by  input/output\nspecifications.\n\nThe following may appear anywhere in a simple command or may precede or\nfollow a complex command.  Expansion occurs before  word  or  digit  is\nused except as noted below.  If the result of substitution on word pro-\nduces more than one filename,  redirection  occurs  for  each  separate\nfilename in turn.\n\n< word Open file word for reading as standard input.  It is an error to\nopen a file in this fashion if it does not exist.\n\n<> word\nOpen file word for reading and writing as  standard  input.   If\nthe file does not exist then it is created.\n\n> word Open file word for writing as standard output.  If the file does\nnot exist then it is created.  If the file exists, and the CLOB-\nBER  option  is  unset,  this  causes an error; otherwise, it is\ntruncated to zero length.\n\n>| word\n>! word\nSame as >, except that the file is truncated to zero  length  if\nit exists, regardless of CLOBBER.\n\n>> word\nOpen  file  word  for writing in append mode as standard output.\nIf the file does not exist, and the  CLOBBER  and  APPENDCREATE\noptions  are  both  unset,  this causes an error; otherwise, the\nfile is created.\n\n>>| word\n>>! word\nSame as >>, except that the file is created if it does  not  ex-\nist, regardless of CLOBBER and APPENDCREATE.\n\n<<[-] word\nThe  shell  input is read up to a line that is the same as word,\nor to an end-of-file.  No parameter expansion, command substitu-\ntion or filename generation is performed on word.  The resulting\ndocument, called a here-document, becomes the standard input.\n\nIf any character of word is quoted with single or double  quotes\nor a `\\', no interpretation is placed upon the characters of the\ndocument.  Otherwise, parameter and command substitution occurs,\n`\\'  followed  by  a newline is removed, and `\\' must be used to\nquote the characters `\\', `$', ``' and the  first  character  of\nword.\n\nNote  that  word itself does not undergo shell expansion.  Back-\nquotes in word do not have their usual effect; instead they  be-\nhave  similarly  to  double  quotes,  except that the backquotes\nthemselves are passed through unchanged.  (This  information  is\ngiven for completeness and it is not recommended that backquotes\nbe used.)  Quotes in the form $'...' have their standard  effect\nof expanding backslashed references to special characters.\n\nIf <<- is used, then all leading tabs are stripped from word and\nfrom the document.\n\n<<< word\nPerform shell expansion on word and pass the result to  standard\ninput.  This is known as a here-string.  Compare the use of word\nin here-documents above, where word does not undergo  shell  ex-\npansion.\n\n<& number\n>& number\nThe  standard  input/output  is  duplicated from file descriptor\nnumber (see dup2(2)).\n\n<& -\n>& -   Close the standard input/output.\n\n<& p\n>& p   The input/output from/to the coprocess is moved to the  standard\ninput/output.\n\n>& word\n&> word\n(Except  where `>& word' matches one of the above syntaxes; `&>'\ncan always be used to avoid  this  ambiguity.)   Redirects  both\nstandard  output  and  standard error (file descriptor 2) in the\nmanner of `> word'.  Note that this does not have the  same  ef-\nfect  as  `> word 2>&1' in the presence of multios (see the sec-\ntion below).\n\n>&| word\n>&! word\n&>| word\n&>! word\nRedirects both standard output and standard error (file descrip-\ntor 2) in the manner of `>| word'.\n\n>>& word\n&>> word\nRedirects both standard output and standard error (file descrip-\ntor 2) in the manner of `>> word'.\n\n>>&| word\n>>&! word\n&>>| word\n&>>! word\nRedirects both standard output and standard error (file descrip-\ntor 2) in the manner of `>>| word'.\n\nIf  one  of  the above is preceded by a digit, then the file descriptor\nreferred to is that specified by the digit instead of the default 0  or\n1.   The order in which redirections are specified is significant.  The\nshell evaluates each redirection in  terms  of  the  (file  descriptor,\nfile) association at the time of evaluation.  For example:\n\n... 1>fname 2>&1\n\nfirst associates file descriptor 1 with file fname.  It then associates\nfile descriptor 2 with the file associated with file descriptor 1 (that\nis,  fname).  If the order of redirections were reversed, file descrip-\ntor 2 would be associated with the terminal (assuming file descriptor 1\nhad  been)  and  then  file  descriptor 1 would be associated with file\nfname.\n\nThe `|&' command separator described in Simple Commands & Pipelines  in\nzshmisc(1) is a shorthand for `2>&1 |'.\n\nThe various forms of process substitution, `<(list)', and `=(list)' for\ninput and `>(list)' for output, are often used together with  redirect-\nion.   For  example,  if  word  in an output redirection is of the form\n`>(list)' then the output is piped to the command represented by  list.\nSee Process Substitution in zshexpn(1).\n",
                "subsections": []
            },
            "OPENING FILE DESCRIPTORS USING PARAMETERS": {
                "content": "When  the shell is parsing arguments to a command, and the shell option\nIGNOREBRACES is not set, a different form of redirection  is  allowed:\ninstead  of  a digit before the operator there is a valid shell identi-\nfier enclosed in braces.  The shell will open  a  new  file  descriptor\nthat is guaranteed to be at least 10 and set the parameter named by the\nidentifier to the file descriptor opened.  No whitespace is allowed be-\ntween the closing brace and the redirection character.  For example:\n\n... {myfd}>&1\n\nThis opens a new file descriptor that is a duplicate of file descriptor\n1 and sets the parameter myfd to the number  of  the  file  descriptor,\nwhich  will  be at least 10.  The new file descriptor can be written to\nusing the syntax >&$myfd.  The file descriptor  remains  open  in  sub-\nshells and forked external executables.\n\nThe  syntax  {varid}>&-,  for example {myfd}>&-, may be used to close a\nfile descriptor opened in this fashion.  Note that the parameter  given\nby varid must previously be set to a file descriptor in this case.\n\nIt  is an error to open or close a file descriptor in this fashion when\nthe parameter is readonly.  However, it is not  an  error  to  read  or\nwrite  a  file  descriptor using <&$param or >&$param if param is read-\nonly.\n\nIf the option CLOBBER is unset, it is an error to open a file  descrip-\ntor  using  a  parameter that is already set to an open file descriptor\npreviously allocated by this mechanism.  Unsetting the parameter before\nusing it for allocating a file descriptor avoids the error.\n\nNote  that this mechanism merely allocates or closes a file descriptor;\nit does not perform any redirections from or to it.  It is usually con-\nvenient  to  allocate  a file descriptor prior to use as an argument to\nexec.  The syntax does not in any case work when  used  around  complex\ncommands  such  as  parenthesised subshells or loops, where the opening\nbrace is interpreted as part of a command list to be  executed  in  the\ncurrent shell.\n\nThe  following shows a typical sequence of allocation, use, and closing\nof a file descriptor:\n\ninteger myfd\nexec {myfd}>~/logs/mylogfile.txt\nprint This is a log message. >&$myfd\nexec {myfd}>&-\n\nNote that the expansion of the variable in the expression  >&$myfd  oc-\ncurs  at the point the redirection is opened.  This is after the expan-\nsion of command arguments and after any redirections to the left on the\ncommand line have been processed.\n",
                "subsections": []
            },
            "MULTIOS": {
                "content": "If the user tries to open a file descriptor for writing more than once,\nthe shell opens the file descriptor as a pipe to a process that  copies\nits  input  to  all the specified outputs, similar to tee, provided the\nMULTIOS option is set, as it is by default.  Thus:\n\ndate >foo >bar\n\nwrites the date to two files, named `foo' and `bar'.  Note that a  pipe\nis an implicit redirection; thus\n\ndate >foo | cat\n\nwrites the date to the file `foo', and also pipes it to cat.\n\nNote  that  the  shell  opens  all  the  files to be used in the multio\nprocess immediately, not at the point they are about to be written.\n\nNote also that redirections are always expanded in order.  This happens\nregardless of the setting of the MULTIOS option, but with the option in\neffect there are additional consequences. For example, the  meaning  of\nthe expression >&1 will change after a previous redirection:\n\ndate >&1 >output\n\nIn  the  case above, the >&1 refers to the standard output at the start\nof the line; the result is similar to the tee command.   However,  con-\nsider:\n\ndate >output >&1\n\nAs redirections are evaluated in order, when the >&1 is encountered the\nstandard output is set to the file output and another copy of the  out-\nput is therefore sent to that file.  This is unlikely to be what is in-\ntended.\n\nIf the MULTIOS option is set, the word after a redirection operator  is\nalso subjected to filename generation (globbing).  Thus\n\n: > *\n\nwill  truncate  all files in the current directory, assuming there's at\nleast one.  (Without the MULTIOS option, it would create an empty  file\ncalled `*'.)  Similarly, you can do\n\necho exit 0 >> *.sh\n\nIf the user tries to open a file descriptor for reading more than once,\nthe shell opens the file descriptor as a pipe to a process that  copies\nall the specified inputs to its output in the order specified, provided\nthe MULTIOS option is set.  It should be noted that each file is opened\nimmediately, not at the point where it is about to be read: this behav-\niour differs from cat, so if strictly standard behaviour is needed, cat\nshould be used instead.\n\nThus\n\nsort <foo <fubar\n\nor even\n\nsort <f{oo,ubar}\n\nis equivalent to `cat foo fubar | sort'.\n\nExpansion of the redirection argument occurs at the point the redirect-\nion is opened, at the point described above for the  expansion  of  the\nvariable in >&$myfd.\n\nNote that a pipe is an implicit redirection; thus\n\ncat bar | sort <foo\n\nis equivalent to `cat bar foo | sort' (note the order of the inputs).\n\nIf  the MULTIOS option is unset, each redirection replaces the previous\nredirection for that file descriptor.  However, all files redirected to\nare actually opened, so\n\necho Hello > bar > baz\n\nwhen  MULTIOS  is  unset  will  truncate  `bar', and write `Hello' into\n`baz'.\n\nThere is a problem when an output multio is  attached  to  an  external\nprogram.  A simple example shows this:\n\ncat file >file1 >file2\ncat file1 file2\n\nHere,  it  is  possible that the second `cat' will not display the full\ncontents of file1 and file2 (i.e. the original  contents  of  file  re-\npeated twice).\n\nThe  reason  for  this  is  that  the multios are spawned after the cat\nprocess is forked from the parent shell, so the parent shell  does  not\nwait for the multios to finish writing data.  This means the command as\nshown can exit before file1 and file2 are  completely  written.   As  a\nworkaround,  it  is possible to run the cat process as part of a job in\nthe current shell:\n\n{ cat file } >file >file2\n\nHere, the {...} job will pause to wait for both files to be written.\n",
                "subsections": []
            },
            "REDIRECTIONS WITH NO COMMAND": {
                "content": "When a simple command consists of one or more redirection operators and\nzero or more parameter assignments, but no command name, zsh can behave\nin several ways.\n\nIf the parameter NULLCMD is not set or the option CSHNULLCMD  is  set,\nan error is caused.  This is the csh behavior and CSHNULLCMD is set by\ndefault when emulating csh.\n\nIf the option SHNULLCMD is set, the builtin `:' is inserted as a  com-\nmand  with  the given redirections.  This is the default when emulating\nsh or ksh.\n\nOtherwise, if the parameter NULLCMD is set, its value will be used as a\ncommand  with  the given redirections.  If both NULLCMD and READNULLCMD\nare set, then the value of the latter will be used instead of  that  of\nthe  former  when the redirection is an input.  The default for NULLCMD\nis `cat' and for READNULLCMD is `more'. Thus\n\n< file\n\nshows the contents of file on standard output, with paging if that is a\nterminal.  NULLCMD and READNULLCMD may refer to shell functions.\n",
                "subsections": []
            },
            "COMMAND EXECUTION": {
                "content": "If a command name contains no slashes, the shell attempts to locate it.\nIf there exists a shell function by that name, the function is  invoked\nas  described  in  the  section  `Functions'.   If there exists a shell\nbuiltin by that name, the builtin is invoked.\n\nOtherwise, the shell searches each element of  $path  for  a  directory\ncontaining  an  executable  file by that name.  If the search is unsuc-\ncessful, the shell prints an error message and returns a  nonzero  exit\nstatus.\n\nIf  execution  fails  because the file is not in executable format, and\nthe file is not a directory, it  is  assumed  to  be  a  shell  script.\n/bin/sh  is  spawned to execute it.  If the program is a file beginning\nwith `#!', the remainder of the first line specifies an interpreter for\nthe program.  The shell will execute the specified interpreter on oper-\nating systems that do not handle this executable format in the kernel.\n\nIf no external command is found but a  function  commandnotfoundhan-\ndler  exists the shell executes this function with all command line ar-\nguments.  The return status of the function becomes the status  of  the\ncommand.   If  the  function wishes to mimic the behaviour of the shell\nwhen the command is not found, it should print the message `command not\nfound:  cmd'  to  standard  error and return status 127.  Note that the\nhandler is executed in a subshell forked to execute  an  external  com-\nmand,  hence changes to directories, shell parameters, etc. have no ef-\nfect on the main shell.\n",
                "subsections": []
            },
            "FUNCTIONS": {
                "content": "Shell functions are defined with the function reserved word or the spe-\ncial  syntax `funcname ()'.  Shell functions are read in and stored in-\nternally.  Alias names are resolved when the function is  read.   Func-\ntions  are  executed  like  commands with the arguments passed as posi-\ntional parameters.  (See the section `Command Execution'.)\n\nFunctions execute in the same process as the caller and share all files\nand  present working directory with the caller.  A trap on EXIT set in-\nside a function is executed after the function completes in  the  envi-\nronment of the caller.\n\nThe return builtin is used to return from function calls.\n\nFunction  identifiers  can be listed with the functions builtin.  Func-\ntions can be undefined with the unfunction builtin.\n",
                "subsections": []
            },
            "AUTOLOADING FUNCTIONS": {
                "content": "A function can be marked as undefined using the  autoload  builtin  (or\n`functions  -u'  or `typeset -fu').  Such a function has no body.  When\nthe function is first executed, the shell searches for  its  definition\nusing the elements of the fpath variable.  Thus to define functions for\nautoloading, a typical sequence is:\n\nfpath=(~/myfuncs $fpath)\nautoload myfunc1 myfunc2 ...\n\nThe usual alias expansion during reading will be suppressed if the  au-\ntoload builtin or its equivalent is given the option -U. This is recom-\nmended for the use of functions supplied  with  the  zsh  distribution.\nNote  that  for functions precompiled with the zcompile builtin command\nthe flag -U must be provided when the .zwc file is created, as the cor-\nresponding information is compiled into the latter.\n\nFor  each  element  in fpath, the shell looks for three possible files,\nthe newest of which is used to load the definition for the function:\n\nelement.zwc\nA file created with the zcompile builtin command, which  is  ex-\npected  to  contain the definitions for all functions in the di-\nrectory named element.  The file is treated in the  same  manner\nas  a  directory  containing files for functions and is searched\nfor the definition of the function.   If the definition  is  not\nfound,  the  search for a definition proceeds with the other two\npossibilities described below.\n\nIf element already includes a .zwc extension (i.e. the extension\nwas  explicitly  given by the user), element is searched for the\ndefinition of the function without comparing its age to that  of\nother  files;  in  fact, there does not need to be any directory\nnamed element without the suffix.   Thus  including  an  element\nsuch as `/usr/local/funcs.zwc' in fpath will speed up the search\nfor functions, with the  disadvantage  that  functions  included\nmust  be  explicitly recompiled by hand before the shell notices\nany changes.\n\nelement/function.zwc\nA file created with zcompile, which is expected to  contain  the\ndefinition  for function.  It may include other function defini-\ntions as well, but those are neither loaded nor executed; a file\nfound  in  this way is searched only for the definition of func-\ntion.\n\nelement/function\nA file of zsh command text, taken to be the definition for func-\ntion.\n\nIn  summary, the order of searching is, first, in the parents of direc-\ntories in fpath for the newer of either a compiled directory or  a  di-\nrectory  in fpath; second, if more than one of these contains a defini-\ntion for the function that is sought, the leftmost in the fpath is cho-\nsen;  and  third,  within  a  directory, the newer of either a compiled\nfunction or an ordinary function definition is used.\n\nIf the KSHAUTOLOAD option is set, or the file contains only  a  simple\ndefinition of the function, the file's contents will be executed.  This\nwill normally define the function in question,  but  may  also  perform\ninitialization, which is executed in the context of the function execu-\ntion, and may therefore define local parameters.  It is an error if the\nfunction is not defined by loading the file.\n\nOtherwise,  the  function body (with no surrounding `funcname() {...}')\nis taken to be the complete contents of the file.  This form allows the\nfile  to be used directly as an executable shell script.  If processing\nof the file results in the function being re-defined, the function  it-\nself  is not re-executed.  To force the shell to perform initialization\nand then call the function defined, the file should contain initializa-\ntion code (which will be executed then discarded) in addition to a com-\nplete function definition (which will be retained for subsequent  calls\nto the function), and a call to the shell function, including any argu-\nments, at the end.\n\nFor example, suppose the autoload file func contains\n\nfunc() { print This is func; }\nprint func is initialized\n\nthen `func; func' with KSHAUTOLOAD set will produce both  messages  on\nthe  first  call, but only the message `This is func' on the second and\nsubsequent calls.  Without KSHAUTOLOAD set, it will produce  the  ini-\ntialization  message  on  the  first call, and the other message on the\nsecond and subsequent calls.\n\nIt is also possible to create a function that  is  not  marked  as  au-\ntoloaded, but which loads its own definition by searching fpath, by us-\ning `autoload -X' within a shell function.  For example, the  following\nare equivalent:\n\nmyfunc() {\nautoload -X\n}\nmyfunc args...\n\nand\n\nunfunction myfunc   # if myfunc was defined\nautoload myfunc\nmyfunc args...\n\nIn  fact,  the  functions  command outputs `builtin autoload -X' as the\nbody of an autoloaded function.  This is done so that\n\neval \"$(functions)\"\n\nproduces a reasonable result.  A true autoloaded function can be  iden-\ntified  by  the  presence of the comment `# undefined' in the body, be-\ncause all comments are discarded from defined functions.\n\nTo load the definition of an autoloaded function myfunc without execut-\ning myfunc, use:\n\nautoload +X myfunc\n",
                "subsections": []
            },
            "ANONYMOUS FUNCTIONS": {
                "content": "If  no  name  is given for a function, it is `anonymous' and is handled\nspecially.  Either form of function definition may be used: a `()' with\nno  preceding  name, or a `function' with an immediately following open\nbrace.  The function is executed immediately at the point of definition\nand  is  not  stored  for  future  use.   The  function  name is set to\n`(anon)'.\n\nArguments to the function may be specified as words following the clos-\ning  brace  defining the function, hence if there are none no arguments\n(other than $0) are set.  This is a difference from the way other func-\ntions  are  parsed: normal function definitions may be followed by cer-\ntain keywords such as `else' or `fi', which will be  treated  as  argu-\nments  to anonymous functions, so that a newline or semicolon is needed\nto force keyword interpretation.\n\nNote also that the argument list of any enclosing script or function is\nhidden  (as  would  be  the  case for any other function called at this\npoint).\n\nRedirections may be applied to the anonymous function in the same  man-\nner  as  to a current-shell structure enclosed in braces.  The main use\nof anonymous functions is to provide a scope for local variables.  This\nis  particularly  convenient  in start-up files as these do not provide\ntheir own local variable scope.\n\nFor example,\n\nvariable=outside\nfunction {\nlocal variable=inside\nprint \"I am $variable with arguments $*\"\n} this and that\nprint \"I am $variable\"\n\noutputs the following:\n\nI am inside with arguments this and that\nI am outside\n\nNote that function definitions with arguments that expand  to  nothing,\nfor  example `name=; function $name { ... }', are not treated as anony-\nmous functions.  Instead, they are treated as normal  function  defini-\ntions where the definition is silently discarded.\n",
                "subsections": []
            },
            "SPECIAL FUNCTIONS": {
                "content": "Certain functions, if defined, have special meaning to the shell.\n\nHook Functions\nFor the functions below, it is possible to define an array that has the\nsame name as the function with `functions' appended.  Any  element  in\nsuch an array is taken as the name of a function to execute; it is exe-\ncuted in the same context and with the  same  arguments  as  the  basic\nfunction.   For example, if $chpwdfunctions is an array containing the\nvalues `mychpwd', `chpwdsavedirstack', then the shell attempts to ex-\necute  the  functions  `chpwd', `mychpwd' and `chpwdsavedirstack', in\nthat order.  Any function that does not exist is silently  ignored.   A\nfunction  found  by  this mechanism is referred to elsewhere as a `hook\nfunction'.  An error in any function causes subsequent functions not to\nbe  run.  Note further that an error in a precmd hook causes an immedi-\nately following periodic function not to run (though it may run at  the\nnext opportunity).\n\nchpwd  Executed whenever the current working directory is changed.\n\nperiodic\nIf  the parameter PERIOD is set, this function is executed every\n$PERIOD seconds, just before a prompt.  Note  that  if  multiple\nfunctions  are  defined  using the array periodicfunctions only\none period is applied to the complete set of functions, and  the\nscheduled time is not reset if the list of functions is altered.\nHence the set of functions is always called together.\n\nprecmd Executed before each prompt.  Note that precommand functions are\nnot  re-executed  simply because the command line is redrawn, as\nhappens, for example, when a notification about an  exiting  job\nis displayed.\n\npreexec\nExecuted  just  after a command has been read and is about to be\nexecuted.  If the history mechanism  is  active  (regardless  of\nwhether  the  line  was  discarded from the history buffer), the\nstring that the user typed is passed as the first argument, oth-\nerwise  it  is an empty string.  The actual command that will be\nexecuted (including expanded aliases) is passed in two different\nforms:  the  second argument is a single-line, size-limited ver-\nsion of the command (with things like function  bodies  elided);\nthe  third  argument  contains  the full text that is being exe-\ncuted.\n\nzshaddhistory\nExecuted when a history line has been  read  interactively,  but\nbefore  it  is executed.  The sole argument is the complete his-\ntory line  (so  that  any  terminating  newline  will  still  be\npresent).\n\nIf  any  of the hook functions returns status 1 (or any non-zero\nvalue other than 2, though this is  not  guaranteed  for  future\nversions  of  the shell) the history line will not be saved, al-\nthough it lingers in the history until the  next  line  is  exe-\ncuted, allowing you to reuse or edit it immediately.\n\nIf  any  of the hook functions returns status 2 the history line\nwill be saved on the internal history list, but not  written  to\nthe  history  file.   In  case of a conflict, the first non-zero\nstatus value is taken.\n\nA hook function may call `fc -p ...' to switch the history  con-\ntext  so  that the history is saved in a different file from the\nthat in the global HISTFILE parameter.   This  is  handled  spe-\ncially:  the history context is automatically restored after the\nprocessing of the history line is finished.\n\nThe following example function works with  one  of  the  options\nINCAPPENDHISTORY  or SHAREHISTORY set, in order that the line\nis written out immediately after the history entry is added.  It\nfirst  adds the history line to the normal history with the new-\nline stripped, which is usually the correct behaviour.  Then  it\nswitches the history context so that the line will be written to\na history file in the current directory.\n\nzshaddhistory() {\nprint -sr -- ${1%%$'\\n'}\nfc -p .zshlocalhistory\n}\n\nzshexit\nExecuted at the point where the main shell is about to exit nor-\nmally.   This  is  not called by exiting subshells, nor when the\nexec precommand modifier is used  before  an  external  command.\nAlso, unlike TRAPEXIT, it is not called when functions exit.\n\nTrap Functions\nThe functions below are treated specially but do not have corresponding\nhook arrays.\n\nTRAPNAL\nIf defined and non-null, this function will be executed whenever\nthe shell catches a signal SIGNAL, where NAL is a signal name as\nspecified for the kill  builtin.   The  signal  number  will  be\npassed as the first parameter to the function.\n\nIf  a  function  of this form is defined and null, the shell and\nprocesses spawned by it will ignore SIGNAL.\n\nThe return status from the function is handled specially.  If it\nis  zero, the signal is assumed to have been handled, and execu-\ntion continues normally.  Otherwise, the shell  will  behave  as\ninterrupted  except  that  the  return status of the trap is re-\ntained.\n\nPrograms terminated by uncaught  signals  typically  return  the\nstatus  128  plus the signal number.  Hence the following causes\nthe handler for SIGINT to print a message, then mimic the  usual\neffect of the signal.\n\nTRAPINT() {\nprint \"Caught SIGINT, aborting.\"\nreturn $(( 128 + $1 ))\n}\n\nThe  functions  TRAPZERR,  TRAPDEBUG and TRAPEXIT are never exe-\ncuted inside other traps.\n\nTRAPDEBUG\nIf the option DEBUGBEFORECMD is set (as it is by default), ex-\necuted  before  each command; otherwise executed after each com-\nmand.  See the description of the trap builtin in zshbuiltins(1)\nfor details of additional features provided in debug traps.\n\nTRAPEXIT\nExecuted  when the shell exits, or when the current function ex-\nits if defined inside a function.  The value of $? at the  start\nof  execution is the exit status of the shell or the return sta-\ntus of the function exiting.\n\nTRAPZERR\nExecuted whenever a command has a non-zero  exit  status.   How-\never,  the function is not executed if the command occurred in a\nsublist followed by `&&' or `||'; only the final  command  in  a\nsublist  of this type causes the trap to be executed.  The func-\ntion TRAPERR acts the same as TRAPZERR on systems where there is\nno SIGERR (this is the usual case).\n\nThe  functions  beginning  `TRAP' may alternatively be defined with the\ntrap builtin:  this may be preferable for some uses.   Setting  a  trap\nwith  one  form removes any trap of the other form for the same signal;\nremoving a trap in either form removes all traps for the  same  signal.\nThe forms\n\nTRAPNAL() {\n# code\n}\n\n('function traps') and\n\ntrap '\n# code\n' NAL\n\n('list  traps')  are  equivalent in most ways, the exceptions being the\nfollowing:\n\no      Function traps have all the properties of normal functions,  ap-\npearing in the list of functions and being called with their own\nfunction context rather than the  context  where  the  trap  was\ntriggered.\n\no      The  return status from function traps is special, whereas a re-\nturn from a list trap causes the surrounding context  to  return\nwith the given status.\n\no      Function  traps  are  not  reset within subshells, in accordance\nwith zsh behaviour; list traps are  reset,  in  accordance  with\nPOSIX behaviour.\n",
                "subsections": []
            },
            "JOBS": {
                "content": "If  the  MONITOR  option  is set, an interactive shell associates a job\nwith each pipeline.  It keeps a table of current jobs, printed  by  the\njobs  command,  and  assigns them small integer numbers.  When a job is\nstarted asynchronously with `&', the shell prints a  line  to  standard\nerror which looks like:\n\n[1] 1234\n\nindicating that the job which was started asynchronously was job number\n1 and had one (top-level) process, whose process ID was 1234.\n\nIf a job is started with `&|' or `&!', then  that  job  is  immediately\ndisowned.   After  startup,  it does not have a place in the job table,\nand is not subject to the job control features described here.\n\nIf you are running a job and wish to do something else you may hit  the\nkey  ^Z (control-Z) which sends a TSTP signal to the current job:  this\nkey may be redefined by the susp option of the external  stty  command.\nThe  shell  will  then  normally  indicate  that the job has been `sus-\npended', and print another prompt.  You can then manipulate  the  state\nof  this  job, putting it in the background with the bg command, or run\nsome other commands and then eventually bring the  job  back  into  the\nforeground  with  the foreground command fg.  A ^Z takes effect immedi-\nately and is like an interrupt in that pending output and unread  input\nare discarded when it is typed.\n\nA job being run in the background will suspend if it tries to read from\nthe terminal.\n\nNote that if the job running in the foreground  is  a  shell  function,\nthen  suspending  it will have the effect of causing the shell to fork.\nThis is necessary to separate the function's state  from  that  of  the\nparent  shell performing the job control, so that the latter can return\nto the command line prompt.  As a result, even if fg is  used  to  con-\ntinue  the job the function will no longer be part of the parent shell,\nand any variables set by the function will not be visible in the parent\nshell.   Thus  the behaviour is different from the case where the func-\ntion was never suspended.  Zsh is different from many other  shells  in\nthis regard.\n\nOne  additional side effect is that use of disown with a job created by\nsuspending shell code in this fashion is delayed: the job can  only  be\ndisowned once any process started from the parent shell has terminated.\nAt that point, the disowned job disappears silently from the job list.\n\nThe same behaviour is found when the shell is  executing  code  as  the\nright  hand  side  of a pipeline or any complex shell construct such as\nif, for, etc., in order that the entire block of code can be managed as\na  single job.  Background jobs are normally allowed to produce output,\nbut this can be disabled by giving the command `stty tostop'.   If  you\nset this tty option, then background jobs will suspend when they try to\nproduce output like they do when they try to read input.\n\nWhen a command is suspended and continued later with  the  fg  or  wait\nbuiltins,  zsh  restores tty modes that were in effect when it was sus-\npended.  This (intentionally) does not apply if the command is  contin-\nued via `kill -CONT', nor when it is continued with bg.\n\nThere are several ways to refer to jobs in the shell.  A job can be re-\nferred to by the process ID of any process of the job or by one of  the\nfollowing:\n\n%number\nThe job with the given number.\n%string\nThe last job whose command line begins with string.\n%?string\nThe last job whose command line contains string.\n%%     Current job.\n%+     Equivalent to `%%'.\n%-     Previous job.\n\nThe shell learns immediately whenever a process changes state.  It nor-\nmally informs you whenever a job becomes blocked  so  that  no  further\nprogress  is possible.  If the NOTIFY option is not set, it waits until\njust before it prints a prompt before it informs you.  All such notifi-\ncations  are  sent directly to the terminal, not to the standard output\nor standard error.\n\nWhen the monitor mode is on, each background job that  completes  trig-\ngers any trap set for CHLD.\n\nWhen  you  try  to leave the shell while jobs are running or suspended,\nyou will be warned that `You have suspended (running) jobs'.   You  may\nuse  the  jobs command to see what they are.  If you do this or immedi-\nately try to exit again, the shell will not warn you a second time; the\nsuspended  jobs will be terminated, and the running jobs will be sent a\nSIGHUP signal, if the HUP option is set.\n\nTo avoid having the shell terminate the running jobs,  either  use  the\nnohup command (see nohup(1)) or the disown builtin.\n",
                "subsections": []
            },
            "SIGNALS": {
                "content": "The INT and QUIT signals for an invoked command are ignored if the com-\nmand is followed by `&' and the MONITOR  option  is  not  active.   The\nshell  itself  always ignores the QUIT signal.  Otherwise, signals have\nthe values inherited by the shell from its parent (but see the  TRAPNAL\nspecial functions in the section `Functions').\n\nCertain  jobs  are run asynchronously by the shell other than those ex-\nplicitly put into the background; even in cases where the  shell  would\nusually wait for such jobs, an explicit exit command or exit due to the\noption ERREXIT will cause the shell to exit without waiting.  Examples\nof  such  asynchronous  jobs  are process substitution, see the section\nPROCESS SUBSTITUTION in the zshexpn(1) manual  page,  and  the  handler\nprocesses for multios, see the section MULTIOS in the zshmisc(1) manual\npage.\n",
                "subsections": []
            },
            "ARITHMETIC EVALUATION": {
                "content": "The shell can perform integer and floating point arithmetic, either us-\ning  the  builtin let, or via a substitution of the form $((...)).  For\nintegers, the shell is usually compiled to use 8-byte  precision  where\nthis is available, otherwise precision is 4 bytes.  This can be tested,\nfor example, by giving the command `print - $(( 12345678901 ))'; if the\nnumber  appears unchanged, the precision is at least 8 bytes.  Floating\npoint arithmetic always uses the `double'  type  with  whatever  corre-\nsponding precision is provided by the compiler and the library.\n\nThe let builtin command takes arithmetic expressions as arguments; each\nis evaluated separately.  Since many of the  arithmetic  operators,  as\nwell  as  spaces, require quoting, an alternative form is provided: for\nany command which begins with a `((', all the characters until a match-\ning  `))'  are  treated as a quoted expression and arithmetic expansion\nperformed as for an argument of  let.   More  precisely,  `((...))'  is\nequivalent  to  `let  \"...\"'.  The return status is 0 if the arithmetic\nvalue of the expression is non-zero, 1 if it is zero, and 2 if an error\noccurred.\n\nFor example, the following statement\n\n(( val = 2 + 1 ))\n\nis equivalent to\n\nlet \"val = 2 + 1\"\n\nboth  assigning  the  value 3 to the shell variable val and returning a\nzero status.\n\nIntegers can be in bases other than 10.  A leading `0x' or `0X' denotes\nhexadecimal and a leading `0b' or `0B' binary.  Integers may also be of\nthe form `base#n', where base is  a  decimal  number  between  two  and\nthirty-six  representing  the arithmetic base and n is a number in that\nbase (for example, `16#ff' is 255 in hexadecimal).  The base# may  also\nbe omitted, in which case base 10 is used.  For backwards compatibility\nthe form `[base]n' is also accepted.\n\nAn integer expression or a base given in the form `base#n' may  contain\nunderscores  (`')  after  the leading digit for visual guidance; these\nare ignored in computation.   Examples  are  1000000  or  0xffffffff\nwhich are equivalent to 1000000 and 0xffffffff respectively.\n\nIt is also possible to specify a base to be used for output in the form\n`[#base]', for example `[#16]'.  This is used  when  outputting  arith-\nmetical  substitutions  or  when assigning to scalar parameters, but an\nexplicitly defined integer or floating point parameter will not be  af-\nfected.   If an integer variable is implicitly defined by an arithmetic\nexpression, any base specified in this way will be  set  as  the  vari-\nable's output arithmetic base as if the option `-i base' to the typeset\nbuiltin had been used.  The expression has no precedence and if it  oc-\ncurs  more than once in a mathematical expression, the last encountered\nis used.  For clarity it is recommended that it appear at the beginning\nof an expression.  As an example:\n\ntypeset -i 16 y\nprint $(( [#8] x = 32, y = 32 ))\nprint $x $y\n\noutputs first `8#40', the rightmost value in the given output base, and\nthen `8#40 16#20', because y has been explicitly declared to have  out-\nput base 16, while x (assuming it does not already exist) is implicitly\ntyped by the arithmetic evaluation, where it acquires the  output  base\n8.\n\nThe base may be replaced or followed by an underscore, which may itself\nbe followed by a positive integer (if it is  missing  the  value  3  is\nused).   This  indicates  that  underscores should be inserted into the\noutput string, grouping the number for visual clarity.   The  following\ninteger specifies the number of digits to group together.  For example:\n\nsetopt cbases\nprint $(( [#164] 65536  2 ))\n\noutputs `0x100000000'.\n\nThe  feature can be used with floating point numbers, in which case the\nbase must be omitted; grouping is away from the decimal point.  For ex-\nample,\n\nzmodload zsh/mathfunc\nprint $(( [#] sqrt(1e7) ))\n\noutputs  `3162.2776601683795'  (the number of decimal places shown\nmay vary).\n\nIf the CBASES option is set, hexadecimal numbers  are  output  in  the\nstandard C format, for example `0xFF' instead of the usual `16#FF'.  If\nthe option OCTALZEROES is also set (it is not by default), octal  num-\nbers  will  be  treated  similarly and hence appear as `077' instead of\n`8#77'.  This option has no effect on the output of  bases  other  than\nhexadecimal  and  octal, and these formats are always understood on in-\nput.\n\nWhen an output base is specified using the `[#base]' syntax, an  appro-\npriate  base prefix will be output if necessary, so that the value out-\nput is valid syntax for input.   If  the  #  is  doubled,  for  example\n`[##16]', then no base prefix is output.\n\nFloating  point  constants  are recognized by the presence of a decimal\npoint or an exponent.  The decimal point may be the first character  of\nthe  constant, but the exponent character e or E may not, as it will be\ntaken for a parameter name.  All numeric parts (before  and  after  the\ndecimal  point  and  in the exponent) may contain underscores after the\nleading digit for visual guidance; these are ignored in computation.\n\nAn arithmetic expression uses nearly the same syntax and  associativity\nof expressions as in C.\n\nIn  the native mode of operation, the following operators are supported\n(listed in decreasing order of precedence):\n\n+ - ! ~ ++ --\nunary plus/minus, logical NOT, complement, {pre,post}{in,de}cre-\nment\n<< >>  bitwise shift left, right\n&      bitwise AND\n^      bitwise XOR\n|      bitwise OR\nexponentiation\n* / %  multiplication, division, modulus (remainder)\n+ -    addition, subtraction\n< > <= >=\ncomparison\n== !=  equality and inequality\n&&     logical AND\n|| ^^  logical OR, XOR\n? :    ternary operator\n= += -= *= /= %= &= ^= |= <<= >>= &&= ||= ^^= =\nassignment\n,      comma operator\n\nThe  operators  `&&',  `||', `&&=', and `||=' are short-circuiting, and\nonly one of the latter two expressions in a ternary operator is  evalu-\nated.  Note the precedence of the bitwise AND, OR, and XOR operators.\n\nWith the option CPRECEDENCES the precedences (but no other properties)\nof the operators are altered to be the same as those in most other lan-\nguages that support the relevant operators:\n\n+ - ! ~ ++ --\nunary plus/minus, logical NOT, complement, {pre,post}{in,de}cre-\nment\nexponentiation\n* / %  multiplication, division, modulus (remainder)\n+ -    addition, subtraction\n<< >>  bitwise shift left, right\n< > <= >=\ncomparison\n== !=  equality and inequality\n&      bitwise AND\n^      bitwise XOR\n|      bitwise OR\n&&     logical AND\n^^     logical XOR\n||     logical OR\n? :    ternary operator\n= += -= *= /= %= &= ^= |= <<= >>= &&= ||= ^^= =\nassignment\n,      comma operator\n\nNote the precedence of exponentiation in both cases is  below  that  of\nunary  operators, hence `-32' evaluates as `9', not `-9'.  Use paren-\ntheses where necessary: `-(32)'.   This  is  for  compatibility  with\nother shells.\n\nMathematical  functions  can  be  called  with the syntax `func(args)',\nwhere the function decides if the  args  is  used  as  a  string  or  a\ncomma-separated list of arithmetic expressions. The shell currently de-\nfines no mathematical functions by default, but the module zsh/mathfunc\nmay  be  loaded  with the zmodload builtin to provide standard floating\npoint mathematical functions.\n\nAn expression of the form `##x' where x is any character sequence  such\nas `a', `^A', or `\\M-\\C-x' gives the value of this character and an ex-\npression of the form `#name' gives the value of the first character  of\nthe  contents of the parameter name.  Character values are according to\nthe character set used in the current locale; for  multibyte  character\nhandling the option MULTIBYTE must be set.  Note that this form is dif-\nferent from `$#name', a standard parameter substitution which gives the\nlength  of  the  parameter name.  `#\\' is accepted instead of `##', but\nits use is deprecated.\n\nNamed parameters and subscripted  arrays  can  be  referenced  by  name\nwithin  an  arithmetic expression without using the parameter expansion\nsyntax.  For example,\n\n((val2 = val1 * 2))\n\nassigns twice the value of $val1 to the parameter named val2.\n\nAn internal integer representation of a named parameter can  be  speci-\nfied  with  the integer builtin.  Arithmetic evaluation is performed on\nthe value of each assignment to a named parameter declared  integer  in\nthis  manner.   Assigning a floating point number to an integer results\nin rounding towards zero.\n\nLikewise, floating  point  numbers  can  be  declared  with  the  float\nbuiltin; there are two types, differing only in their output format, as\ndescribed for the typeset builtin.  The output format can  be  bypassed\nby using arithmetic substitution instead of the parameter substitution,\ni.e. `${float}' uses  the  defined  format,  but  `$((float))'  uses  a\ngeneric floating point format.\n\nPromotion of integer to floating point values is performed where neces-\nsary.  In addition, if any operator which  requires  an  integer  (`&',\n`|',  `^', `<<', `>>' and their equivalents with assignment) is given a\nfloating point argument, it will be silently rounded towards  zero  ex-\ncept for `~' which rounds down.\n\nUsers  should  beware  that, in common with many other programming lan-\nguages but not software designed for calculation, the evaluation of  an\nexpression  in  zsh is taken a term at a time and promotion of integers\nto floating point does not occur in terms only containing integers.   A\ntypical  result of this is that a division such as 6/8 is truncated, in\nthis being rounded towards 0.  The FORCEFLOAT shell option can be used\nin  scripts  or  functions  where floating point evaluation is required\nthroughout.\n\nScalar variables can hold integer or floating point values at different\ntimes; there is no memory of the numeric type in this case.\n\nIf a variable is first assigned in a numeric context without previously\nbeing declared, it will be implicitly typed as integer or float and re-\ntain that type either until the type is explicitly changed or until the\nend of the scope.  This can have unforeseen consequences.  For example,\nin the loop\n\nfor (( f = 0; f < 1; f += 0.1 )); do\n# use $f\ndone\n\nif  f has not already been declared, the first assignment will cause it\nto be created as an integer, and consequently the operation `f +=  0.1'\nwill  always cause the result to be truncated to zero, so that the loop\nwill fail.  A simple fix would be to turn the initialization into `f  =\n0.0'.   It is therefore best to declare numeric variables with explicit\ntypes.\n",
                "subsections": []
            },
            "CONDITIONAL EXPRESSIONS": {
                "content": "A conditional expression is used with the [[ compound command  to  test\nattributes  of  files  and  to compare strings.  Each expression can be\nconstructed from one or more of the following unary or  binary  expres-\nsions:\n\n-a file\ntrue if file exists.\n\n-b file\ntrue if file exists and is a block special file.\n\n-c file\ntrue if file exists and is a character special file.\n\n-d file\ntrue if file exists and is a directory.\n\n-e file\ntrue if file exists.\n\n-f file\ntrue if file exists and is a regular file.\n\n-g file\ntrue if file exists and has its setgid bit set.\n\n-h file\ntrue if file exists and is a symbolic link.\n\n-k file\ntrue if file exists and has its sticky bit set.\n\n-n string\ntrue if length of string is non-zero.\n\n-o option\ntrue if option named option is on.  option may be a single char-\nacter, in which case it is a single letter  option  name.   (See\nthe section `Specifying Options'.)\n\nWhen  no  option named option exists, and the POSIXBUILTINS op-\ntion hasn't been set, return 3 with a warning.  If  that  option\nis set, return 1 with no warning.\n\n-p file\ntrue if file exists and is a FIFO special file (named pipe).\n\n-r file\ntrue if file exists and is readable by current process.\n\n-s file\ntrue if file exists and has size greater than zero.\n\n-t fd  true  if file descriptor number fd is open and associated with a\nterminal device.  (note: fd is not optional)\n\n-u file\ntrue if file exists and has its setuid bit set.\n\n-v varname\ntrue if shell variable varname is set.\n\n-w file\ntrue if file exists and is writable by current process.\n\n-x file\ntrue if file exists and is executable by  current  process.   If\nfile  exists  and  is  a directory, then the current process has\npermission to search in the directory.\n\n-z string\ntrue if length of string is zero.\n\n-L file\ntrue if file exists and is a symbolic link.\n\n-O file\ntrue if file exists and is owned by the  effective  user  ID  of\nthis process.\n\n-G file\ntrue if file exists and its group matches the effective group ID\nof this process.\n\n-S file\ntrue if file exists and is a socket.\n\n-N file\ntrue if file exists and its access time is not  newer  than  its\nmodification time.\n\nfile1 -nt file2\ntrue if file1 exists and is newer than file2.\n\nfile1 -ot file2\ntrue if file1 exists and is older than file2.\n\nfile1 -ef file2\ntrue if file1 and file2 exist and refer to the same file.\n\nstring = pattern\nstring == pattern\ntrue  if  string  matches  pattern.   The  two forms are exactly\nequivalent.  The `=' form is the traditional shell  syntax  (and\nhence the only one generally used with the test and [ builtins);\nthe `==' form provides compatibility with other  sorts  of  com-\nputer language.\n\nstring != pattern\ntrue if string does not match pattern.\n\nstring =~ regexp\ntrue  if  string  matches the regular expression regexp.  If the\noption REMATCHPCRE is set regexp is tested as a  PCRE  regular\nexpression  using  the  zsh/pcre  module, else it is tested as a\nPOSIX extended regular expression using  the  zsh/regex  module.\nUpon  successful match, some variables will be updated; no vari-\nables are changed if the matching fails.\n\nIf the option BASHREMATCH is not set the scalar parameter MATCH\nis set to the substring that matched the pattern and the integer\nparameters MBEGIN and MEND to the index of the  start  and  end,\nrespectively,  of  the  match  in string, such that if string is\ncontained in variable var the expression `${var[$MBEGIN,$MEND]}'\nis  identical to `$MATCH'.  The setting of the option KSHARRAYS\nis respected.  Likewise, the array match  is  set  to  the  sub-\nstrings that matched parenthesised subexpressions and the arrays\nmbegin and mend to the indices of the start and  end  positions,\nrespectively,  of  the substrings within string.  The arrays are\nnot set if there were no parenthesised subexpressions.  For  ex-\nample,  if  the  string  `a short string' is matched against the\nregular expression `s(...)t', then (assuming the option  KSHAR-\nRAYS  is  not  set) MATCH, MBEGIN and MEND are `short', 3 and 7,\nrespectively, while match, mbegin and mend are single entry  ar-\nrays containing the strings `hor', `4' and `6', respectively.\n\nIf  the option BASHREMATCH is set the array BASHREMATCH is set\nto the substring that matched the pattern followed by  the  sub-\nstrings  that  matched  parenthesised  subexpressions within the\npattern.\n\nstring1 < string2\ntrue if string1 comes before string2 based  on  ASCII  value  of\ntheir characters.\n\nstring1 > string2\ntrue  if  string1  comes  after  string2 based on ASCII value of\ntheir characters.\n\nexp1 -eq exp2\ntrue if exp1 is numerically equal to exp2.  Note that for purely\nnumeric  comparisons use of the ((...)) builtin described in the\nsection `ARITHMETIC EVALUATION' is more convenient  than  condi-\ntional expressions.\n\nexp1 -ne exp2\ntrue if exp1 is numerically not equal to exp2.\n\nexp1 -lt exp2\ntrue if exp1 is numerically less than exp2.\n\nexp1 -gt exp2\ntrue if exp1 is numerically greater than exp2.\n\nexp1 -le exp2\ntrue if exp1 is numerically less than or equal to exp2.\n\nexp1 -ge exp2\ntrue if exp1 is numerically greater than or equal to exp2.\n\n( exp )\ntrue if exp is true.\n\n! exp  true if exp is false.\n\nexp1 && exp2\ntrue if exp1 and exp2 are both true.\n\nexp1 || exp2\ntrue if either exp1 or exp2 is true.\n\nFor  compatibility, if there is a single argument that is not syntacti-\ncally significant, typically a variable, the condition is treated as  a\ntest for whether the expression expands as a string of non-zero length.\nIn other words, [[ $var ]] is the same as [[ -n $var ]].  It is  recom-\nmended that the second, explicit, form be used where possible.\n\nNormal shell expansion is performed on the file, string and pattern ar-\nguments, but the result of each expansion is constrained to be a single\nword, similar to the effect of double quotes.\n\nFilename  generation is not performed on any form of argument to condi-\ntions.  However, it can be forced in any case where normal shell expan-\nsion  is  valid and when the option EXTENDEDGLOB is in effect by using\nan explicit glob qualifier of the form (#q) at the end of  the  string.\nA  normal  glob qualifier expression may appear between the `q' and the\nclosing parenthesis; if none appears the expression has no  effect  be-\nyond  causing  filename generation.  The results of filename generation\nare joined together to form a single word, as with the results of other\nforms of expansion.\n\nThis  special  use of filename generation is only available with the [[\nsyntax.  If the condition occurs within the [ or test builtin  commands\nthen  globbing  occurs instead as part of normal command line expansion\nbefore the condition is evaluated.  In this case it may generate multi-\nple words which are likely to confuse the syntax of the test command.\n\nFor example,\n\n[[ -n file*(#qN) ]]\n\nproduces  status  zero if and only if there is at least one file in the\ncurrent directory beginning with the string `file'.  The globbing qual-\nifier  N  ensures  that the expression is empty if there is no matching\nfile.\n\nPattern metacharacters are active for the pattern arguments;  the  pat-\nterns  are  the  same  as  those used for filename generation, see zsh-\nexpn(1), but there is no special behaviour of `/' nor initial dots, and\nno glob qualifiers are allowed.\n\nIn  each  of the above expressions, if file is of the form `/dev/fd/n',\nwhere n is an integer, then the test applied to the open file whose de-\nscriptor  number  is  n, even if the underlying system does not support\nthe /dev/fd directory.\n\nIn the forms which do numeric comparison, the expressions  exp  undergo\narithmetic expansion as if they were enclosed in $((...)).\n\nFor example, the following:\n\n[[ ( -f foo || -f bar ) && $report = y* ]] && print File exists.\n\ntests if either file foo or file bar exists, and if so, if the value of\nthe parameter report begins with `y';  if  the  complete  condition  is\ntrue, the message `File exists.' is printed.\n",
                "subsections": []
            },
            "EXPANSION OF PROMPT SEQUENCES": {
                "content": "Prompt sequences undergo a special form of expansion.  This type of ex-\npansion is also available using the -P option to the print builtin.\n\nIf the PROMPTSUBST option is set, the prompt string is first subjected\nto  parameter expansion, command substitution and arithmetic expansion.\nSee zshexpn(1).\n\nCertain escape sequences may be recognised in the prompt string.\n\nIf the PROMPTBANG option is set, a `!' in the prompt  is  replaced  by\nthe  current  history  event  number.  A literal `!' may then be repre-\nsented as `!!'.\n\nIf the PROMPTPERCENT option is  set,  certain  escape  sequences  that\nstart  with  `%'  are  expanded.  Many escapes are followed by a single\ncharacter, although some of these take  an  optional  integer  argument\nthat  should  appear  between the `%' and the next character of the se-\nquence.  More complicated escape sequences  are  available  to  provide\nconditional expansion.\n",
                "subsections": []
            },
            "SIMPLE PROMPT ESCAPES": {
                "content": "Special characters\n%%     A `%'.\n\n%)     A `)'.\n\nLogin information\n%l     The line (tty) the user is logged in on, without `/dev/' prefix.\nIf the name starts with `/dev/tty', that prefix is stripped.\n\n%M     The full machine hostname.\n\n%m     The hostname up to the first `.'.  An integer may follow the `%'\nto  specify  how  many  components  of the hostname are desired.\nWith a negative integer, trailing components of the hostname are\nshown.\n\n%n     $USERNAME.\n\n%y     The line (tty) the user is logged in on, without `/dev/' prefix.\nThis does not treat `/dev/tty' names specially.\n\nShell state\n%#     A `#' if the shell is running with privileges,  a  `%'  if  not.\nEquivalent  to `%(!.#.%%)'.  The definition of `privileged', for\nthese purposes, is that either the effective user  ID  is  zero,\nor,  if  POSIX.1e  capabilities are supported, that at least one\ncapability is raised in either the Effective or Inheritable  ca-\npability vectors.\n\n%?     The  return  status of the last command executed just before the\nprompt.\n\n%     The status of the parser, i.e. the shell constructs  (like  `if'\nand  `for') that have been started on the command line. If given\nan integer number that many strings will  be  printed;  zero  or\nnegative  or  no integer means print as many as there are.  This\nis most useful in prompts PS2 for continuation lines and PS4 for\ndebugging  with  the  XTRACE  option; in the latter case it will\nalso work non-interactively.\n\n%^     The status of the parser in reverse. This is the  same  as  `%'\nother than the order of strings.  It is often used in RPS2.\n\n%d\n%/     Current  working  directory.   If an integer follows the `%', it\nspecifies a number of trailing components of the current working\ndirectory  to show; zero means the whole path.  A negative inte-\nger specifies leading components, i.e. %-1d specifies the  first\ncomponent.\n\n%~     As  %d  and %/, but if the current working directory starts with\n$HOME, that part is replaced by a `~'. Furthermore, if it has  a\nnamed  directory  as  its prefix, that part is replaced by a `~'\nfollowed by the name of the directory, but only if the result is\nshorter  than the full path; see Dynamic and Static named direc-\ntories in zshexpn(1).\n\n%e     Evaluation depth of the current sourced file, shell function, or\neval.   This  is incremented or decremented every time the value\nof %N is set or reverted  to  a  previous  value,  respectively.\nThis is most useful for debugging as part of $PS4.\n\n%h\n%!     Current history event number.\n\n%i     The  line number currently being executed in the script, sourced\nfile, or shell function given by %N.  This is  most  useful  for\ndebugging as part of $PS4.\n\n%I     The  line  number currently being executed in the file %x.  This\nis similar to %i, but the line number is always a line number in\nthe file where the code was defined, even if the code is a shell\nfunction.\n\n%j     The number of jobs.\n\n%L     The current value of $SHLVL.\n\n%N     The name of the script, sourced file, or shell function that zsh\nis currently executing, whichever was started most recently.  If\nthere is none, this is equivalent to the parameter $0.  An inte-\nger may follow the `%' to specify a number of trailing path com-\nponents to show; zero means the full path.  A  negative  integer\nspecifies leading components.\n\n%x     The  name of the file containing the source code currently being\nexecuted.  This behaves as %N except that function and eval com-\nmand  names  are not shown, instead the file where they were de-\nfined.\n\n%c\n%.\n%C     Trailing component of the current working directory.  An integer\nmay  follow the `%' to get more than one component.  Unless `%C'\nis used, tilde contraction is performed first.  These are depre-\ncated  as %c and %C are equivalent to %1~ and %1/, respectively,\nwhile explicit positive integers have the same effect as for the\nlatter two sequences.\n\nDate and time\n%D     The date in yy-mm-dd format.\n\n%T     Current time of day, in 24-hour format.\n\n%t\n%@     Current time of day, in 12-hour, am/pm format.\n\n%*     Current time of day in 24-hour format, with seconds.\n\n%w     The date in day-dd format.\n\n%W     The date in mm/dd/yy format.\n\n%D{string}\nstring  is  formatted  using  the  strftime function.  See strf-\ntime(3) for more details.  Various zsh extensions  provide  num-\nbers  with  no  leading  zero or space if the number is a single\ndigit:\n\n%f     a day of the month\n%K     the hour of the day on the 24-hour clock\n%L     the hour of the day on the 12-hour clock\n\nIn addition, if the system supports the POSIX gettimeofday  sys-\ntem  call,  %.  provides decimal fractions of a second since the\nepoch with leading zeroes.  By default three decimal places  are\nprovided,  but a number of digits up to 9 may be given following\nthe %; hence %6.  outputs microseconds, and %9. outputs nanosec-\nonds.   (The  latter  requires a nanosecond-precision clockget-\ntime; systems lacking this will return a value multiplied by the\nappropriate power of 10.)  A typical example of this is the for-\nmat `%D{%H:%M:%S.%.}'.\n\nThe GNU extension %N is handled as a synonym for %9..\n\nAdditionally, the GNU extension that a `-' between the % and the\nformat  character  causes a leading zero or space to be stripped\nis handled directly by the shell for the format characters d, f,\nH, k, l, m, M, S and y; any other format characters are provided\nto the system's strftime(3) with any leading `-' present, so the\nhandling is system dependent.  Further GNU (or other) extensions\nare also passed to strftime(3) and may work if the  system  sup-\nports them.\n\nVisual effects\n%B (%b)\nStart (stop) boldface mode.\n\n%E     Clear to end of line.\n\n%U (%u)\nStart (stop) underline mode.\n\n%S (%s)\nStart (stop) standout mode.\n\n%F (%f)\nStart  (stop)  using a different foreground colour, if supported\nby the terminal.  The colour may be specified two  ways:  either\nas  a  numeric  argument,  as normal, or by a sequence in braces\nfollowing the %F, for example %F{red}.  In the latter  case  the\nvalues  allowed are as described for the fg zlehighlight attri-\nbute; see Character Highlighting in zshzle(1).  This means  that\nnumeric colours are allowed in the second format also.\n\n%K (%k)\nStart (stop) using a different bacKground colour.  The syntax is\nidentical to that for %F and %f.\n\n%{...%}\nInclude a string as  a  literal  escape  sequence.   The  string\nwithin  the braces should not change the cursor position.  Brace\npairs can nest.\n\nA positive numeric argument between the % and the {  is  treated\nas described for %G below.\n\n%G     Within  a  %{...%} sequence, include a `glitch': that is, assume\nthat a single character width will be output.   This  is  useful\nwhen  outputting  characters  that otherwise cannot be correctly\nhandled by the shell, such as the  alternate  character  set  on\nsome  terminals.   The  characters  in  question can be included\nwithin a %{...%} sequence together with the  appropriate  number\nof  %G  sequences to indicate the correct width.  An integer be-\ntween the `%' and `G' indicates a  character  width  other  than\none.   Hence  %{seq%2G%} outputs seq and assumes it takes up the\nwidth of two standard characters.\n\nMultiple uses of %G accumulate in the obvious fashion; the posi-\ntion  of  the %G is unimportant.  Negative integers are not han-\ndled.\n\nNote that when prompt truncation is in use it  is  advisable  to\ndivide  up  output  into  single  characters within each %{...%}\ngroup so that the correct truncation point can be found.\n",
                "subsections": []
            },
            "CONDITIONAL SUBSTRINGS IN PROMPTS": {
                "content": "%v     The value of the first element of  the  psvar  array  parameter.\nFollowing  the `%' with an integer gives that element of the ar-\nray.  Negative integers count from the end of the array.\n\n%(x.true-text.false-text)\nSpecifies a ternary expression.  The character following  the  x\nis  arbitrary;  the  same character is used to separate the text\nfor the `true' result from that for the  `false'  result.   This\nseparator  may  not appear in the true-text, except as part of a\n%-escape sequence.  A `)' may appear in the false-text as  `%)'.\ntrue-text and false-text may both contain arbitrarily-nested es-\ncape sequences, including further ternary expressions.\n\nThe left parenthesis may be preceded or followed by  a  positive\ninteger  n,  which defaults to zero.  A negative integer will be\nmultiplied by -1, except as noted below for `l'.  The test char-\nacter x may be any of the following:\n\n!      True if the shell is running with privileges.\n#      True if the effective uid of the current process is n.\n?      True if the exit status of the last command was n.\nTrue if at least n shell constructs were started.\nC\n/      True if the current absolute path has at least n elements\nrelative to the root directory, hence / is counted  as  0\nelements.\nc\n.\n~      True if the current path, with prefix replacement, has at\nleast n elements relative to the root directory, hence  /\nis counted as 0 elements.\nD      True if the month is equal to n (January = 0).\nd      True if the day of the month is equal to n.\ne      True if the evaluation depth is at least n.\ng      True if the effective gid of the current process is n.\nj      True if the number of jobs is at least n.\nL      True if the SHLVL parameter is at least n.\nl      True  if  at least n characters have already been printed\non the current line.  When n  is  negative,  true  if  at\nleast abs(n) characters remain before the opposite margin\n(thus the left margin for RPROMPT).\nS      True if the SECONDS parameter is at least n.\nT      True if the time in hours is equal to n.\nt      True if the time in minutes is equal to n.\nv      True if the array psvar has at least n elements.\nV      True  if  element  n  of  the  array  psvar  is  set  and\nnon-empty.\nw      True if the day of the week is equal to n (Sunday = 0).\n\n%<string<\n%>string>\n%[xstring]\nSpecifies  truncation  behaviour for the remainder of the prompt\nstring.   The  third,  deprecated,   form   is   equivalent   to\n`%xstringx',  i.e. x may be `<' or `>'.  The string will be dis-\nplayed in place of the truncated portion  of  any  string;  note\nthis does not undergo prompt expansion.\n\nThe numeric argument, which in the third form may appear immedi-\nately after the `[', specifies the maximum permitted  length  of\nthe various strings that can be displayed in the prompt.  In the\nfirst two forms, this numeric argument may be negative, in which\ncase  the truncation length is determined by subtracting the ab-\nsolute value of the numeric argument from the number of  charac-\nter positions remaining on the current prompt line.  If this re-\nsults in a zero or negative length, a length of 1 is  used.   In\nother  words, a negative argument arranges that after truncation\nat least n characters remain before the right margin (left  mar-\ngin for RPROMPT).\n\nThe  forms  with `<' truncate at the left of the string, and the\nforms with `>' truncate at the right of the string.   For  exam-\nple,  if  the  current  directory  is  `/home/pike',  the prompt\n`%8<..<%/' will expand to `..e/pike'.  In this string, the  ter-\nminating  character (`<', `>' or `]'), or in fact any character,\nmay be quoted by a preceding `\\'; note when using print -P, how-\never, that this must be doubled as the string is also subject to\nstandard print processing, in addition to  any  backslashes  re-\nmoved  by  a  double quoted string:  the worst case is therefore\n`print -P \"%<\\\\\\\\<<...\"'.\n\nIf the string is longer than the specified truncation length, it\nwill appear in full, completely replacing the truncated string.\n\nThe part of the prompt string to be truncated runs to the end of\nthe string, or to the end of the next  enclosing  group  of  the\n`%('  construct,  or  to  the next truncation encountered at the\nsame grouping level (i.e. truncations inside a  `%('  are  sepa-\nrate), which ever comes first.  In particular, a truncation with\nargument zero (e.g., `%<<') marks the end of the  range  of  the\nstring  to  be truncated while turning off truncation from there\non. For example, the prompt  `%10<...<%~%<<%#  '  will  print  a\ntruncated representation of the current directory, followed by a\n`%' or `#', followed by a space.  Without the `%<<',  those  two\ncharacters  would  be  included  in  the string to be truncated.\nNote that `%-0<<' is not equivalent to `%<<' but specifies  that\nthe prompt is truncated at the right margin.\n\nTruncation  applies  only  within  each  individual  line of the\nprompt, as delimited by embedded newlines (if any).  If the  to-\ntal length of any line of the prompt after truncation is greater\nthan the terminal width, or if the part to be truncated contains\nembedded  newlines,  truncation  behavior  is  undefined and may\nchange   in   a   future   version   of    the    shell.     Use\n`%-n(l.true-text.false-text)' to remove parts of the prompt when\nthe available space is less than n.\n\nzsh 5.8.1                      February 12, 2022                    ZSHMISC(1)",
                "subsections": []
            }
        }
    }
}