1ZSHPARAM(1)                 General Commands Manual                ZSHPARAM(1)
2
3
4

NAME

6       zshparam - zsh parameters
7

DESCRIPTION

9       A  parameter  has  a name, a value, and a number of attributes.  A name
10       may be any sequence of alphanumeric characters and underscores, or  the
11       single  characters  `*',  `@', `#', `?', `-', `$', or `!'.  A parameter
12       whose name begins with an alphanumeric or underscore is  also  referred
13       to as a variable.
14
15       The  attributes  of  a parameter determine the type of its value, often
16       referred to as the parameter type or variable type,  and  also  control
17       other  processing  that  may  be applied to the value when it is refer‐
18       enced.  The value type may be a scalar (a  string,  an  integer,  or  a
19       floating  point number), an array (indexed numerically), or an associa‐
20       tive array (an unordered set of name-value pairs, indexed by name, also
21       referred to as a hash).
22
23       Named  scalar  parameters may have the exported, -x, attribute, to copy
24       them into the process environment, which is then passed from the  shell
25       to  any  new  processes that it starts.  Exported parameters are called
26       environment variables. The shell also imports environment variables  at
27       startup  time  and  automatically marks the corresponding parameters as
28       exported.  Some environment variables are not imported for  reasons  of
29       security  or because they would interfere with the correct operation of
30       other shell features.
31
32       Parameters may also be special, that  is,  they  have  a  predetermined
33       meaning  to  the  shell.   Special  parameters  cannot  have their type
34       changed or their readonly attribute turned off, and if a special param‐
35       eter is unset, then later recreated, the special properties will be re‐
36       tained.
37
38       To declare the type of a parameter, or to assign a  string  or  numeric
39       value to a scalar parameter, use the typeset builtin.
40
41       The value of a scalar parameter may also be assigned by writing:
42
43              name=value
44
45       In  scalar  assignment,  value is expanded as a single string, in which
46       the elements of arrays are joined together; filename expansion  is  not
47       performed unless the option GLOB_ASSIGN is set.
48
49       When  the  integer  attribute, -i, or a floating point attribute, -E or
50       -F, is set for name, the value is  subject  to  arithmetic  evaluation.
51       Furthermore, by replacing `=' with `+=', a parameter can be incremented
52       or appended to.  See the  section  `Array  Parameters'  and  Arithmetic
53       Evaluation (in zshmisc(1)) for additional forms of assignment.
54
55       Note  that assignment may implicitly change the attributes of a parame‐
56       ter.  For example, assigning a number to a variable in arithmetic eval‐
57       uation  may  change  its type to integer or float, and with GLOB_ASSIGN
58       assigning a pattern to a variable may change its type to an array.
59
60       To reference the value of a parameter, write `$name' or `${name}'.  See
61       Parameter  Expansion  in zshexpn(1) for complete details.  That section
62       also explains the effect of the difference between scalar and array as‐
63       signment on parameter expansion.
64

ARRAY PARAMETERS

66       To assign an array value, write one of:
67
68              set -A name value ...
69              name=(value ...)
70              name=([key]=value ...)
71
72       If  no  parameter  name exists, an ordinary array parameter is created.
73       If the parameter name exists and is a scalar, it is replaced by  a  new
74       array.
75
76       In  the  third  form,  key  is  an expression that will be evaluated in
77       arithmetic context (in its simplest form, an integer)  that  gives  the
78       index  of the element to be assigned with value.  In this form any ele‐
79       ments not explicitly mentioned that come before the  largest  index  to
80       which  a  value  is assigned are assigned an empty string.  The indices
81       may be in any order.  Note that this syntax is strict: [  and  ]=  must
82       not  be  quoted, and key may not consist of the unquoted string ]=, but
83       is otherwise treated as a simple string.  The enhanced  forms  of  sub‐
84       script  expression  that may be used when directly subscripting a vari‐
85       able name, described in the section Array  Subscripts  below,  are  not
86       available.
87
88       The  syntaxes  with  and without the explicit key may be mixed.  An im‐
89       plicit key is deduced by incrementing the index from the previously as‐
90       signed  element.  Note that it is not treated as an error if latter as‐
91       signments in this form overwrite earlier assignments.
92
93       For example, assuming the option KSH_ARRAYS is not set, the following:
94
95              array=(one [3]=three four)
96
97       causes the array variable array to contain four elements one, an  empty
98       string, three and four, in that order.
99
100       In the forms where only value is specified, full command line expansion
101       is performed.
102
103       In the [key]=value form, both key and value undergo all forms of expan‐
104       sion  allowed  for  single word shell expansions (this does not include
105       filename generation); these are as performed by the parameter expansion
106       flag  (e)  as described in zshexpn(1).  Nested parentheses may surround
107       value and are included as part of the value, which  is  joined  into  a
108       plain  string; this differs from ksh which allows the values themselves
109       to be arrays.  A future version of zsh may support that.  To cause  the
110       brackets  to  be  interpreted as a character class for filename genera‐
111       tion, and therefore to treat the resulting list of files as  a  set  of
112       values, quote the equal sign using any form of quoting.  Example:
113
114              name=([a-z]'='*)
115
116       To  append to an array without changing the existing values, use one of
117       the following:
118
119              name+=(value ...)
120              name+=([key]=value ...)
121
122       In the second form key may specify an existing index as well as an  in‐
123       dex  off the end of the old array; any existing value is overwritten by
124       value.  Also, it is possible to use [key]+=value to append to  the  ex‐
125       isting value at that index.
126
127       Within the parentheses on the right hand side of either form of the as‐
128       signment, newlines and semicolons are treated the same as white  space,
129       separating individual values.  Any consecutive sequence of such charac‐
130       ters has the same effect.
131
132       Ordinary array parameters may also be explicitly declared with:
133
134              typeset -a name
135
136       Associative arrays must be declared before assignment, by using:
137
138              typeset -A name
139
140       When name refers to an associative array, the list in an assignment  is
141       interpreted as alternating keys and values:
142
143              set -A name key value ...
144              name=(key value ...)
145              name=([key]=value ...)
146
147       Note  that  only one of the two syntaxes above may be used in any given
148       assignment; the forms may not be mixed.  This is unlike the case of nu‐
149       merically indexed arrays.
150
151       Every  key  must  have a value in this case.  Note that this assigns to
152       the entire array, deleting any elements that do not appear in the list.
153       The append syntax may also be used with an associative array:
154
155              name+=(key value ...)
156              name+=([key]=value ...)
157
158       This  adds  a new key/value pair if the key is not already present, and
159       replaces the value for the existing key if it is.  In the  second  form
160       it is also possible to use [key]+=value to append to the existing value
161       at that key.  Expansion is performed identically to  the  corresponding
162       forms for normal arrays, as described above.
163
164       To create an empty array (including associative arrays), use one of:
165
166              set -A name
167              name=()
168
169   Array Subscripts
170       Individual  elements  of an array may be selected using a subscript.  A
171       subscript of the form `[exp]' selects the single element exp, where exp
172       is  an arithmetic expression which will be subject to arithmetic expan‐
173       sion as if it were surrounded by `$((...))'.  The elements are numbered
174       beginning  with  1,  unless  the KSH_ARRAYS option is set in which case
175       they are numbered from zero.
176
177       Subscripts may be used inside braces used to delimit a parameter  name,
178       thus  `${foo[2]}' is equivalent to `$foo[2]'.  If the KSH_ARRAYS option
179       is set, the braced form is the only one that works,  as  bracketed  ex‐
180       pressions otherwise are not treated as subscripts.
181
182       If the KSH_ARRAYS option is not set, then by default accesses to an ar‐
183       ray element with a subscript that evaluates to  zero  return  an  empty
184       string,  while an attempt to write such an element is treated as an er‐
185       ror.  For backward compatibility the KSH_ZERO_SUBSCRIPT option  can  be
186       set  to  cause  subscript  values 0 and 1 to be equivalent; see the de‐
187       scription of the option in zshoptions(1).
188
189       The same subscripting syntax is used  for  associative  arrays,  except
190       that  no  arithmetic expansion is applied to exp.  However, the parsing
191       rules for arithmetic expressions still apply,  which  affects  the  way
192       that  certain special characters must be protected from interpretation.
193       See Subscript Parsing below for details.
194
195       A subscript of the form `[*]' or `[@]' evaluates to all elements of  an
196       array;  there  is no difference between the two except when they appear
197       within double  quotes.   `"$foo[*]"'  evaluates  to  `"$foo[1]  $foo[2]
198       ..."', whereas `"$foo[@]"' evaluates to `"$foo[1]" "$foo[2]" ...'.  For
199       associative arrays, `[*]' or `[@]' evaluate to all the  values,  in  no
200       particular order.  Note that this does not substitute the keys; see the
201       documentation for the `k' flag under Parameter Expansion Flags in  zsh‐
202       expn(1) for complete details.  When an array parameter is referenced as
203       `$name' (with no subscript) it  evaluates  to  `$name[*]',  unless  the
204       KSH_ARRAYS  option  is  set  in which case it evaluates to `${name[0]}'
205       (for an associative array, this means the value of the key  `0',  which
206       may not exist even if there are values for other keys).
207
208       A subscript of the form `[exp1,exp2]' selects all elements in the range
209       exp1 to exp2, inclusive. (Associative arrays are unordered, and  so  do
210       not  support  ranges.) If one of the subscripts evaluates to a negative
211       number, say -n, then the nth element from the end of the array is used.
212       Thus `$foo[-3]' is the third element from the end of the array foo, and
213       `$foo[1,-1]' is the same as `$foo[*]'.
214
215       Subscripting may also be performed on non-array values, in  which  case
216       the  subscripts  specify  a substring to be extracted.  For example, if
217       FOO is set to `foobar', then `echo $FOO[2,5]' prints `ooba'.  Note that
218       some  forms  of  subscripting described below perform pattern matching,
219       and in that case the substring extends from the start of the  match  of
220       the  first  subscript  to the end of the match of the second subscript.
221       For example,
222
223              string="abcdefghijklm"
224              print ${string[(r)d?,(r)h?]}
225
226       prints `defghi'.  This is an obvious generalisation  of  the  rule  for
227       single-character  matches.  For a single subscript, only a single char‐
228       acter is referenced (not the range of characters covered by the match).
229
230       Note that in substring operations the second subscript is handled  dif‐
231       ferently  by the r and R subscript flags: the former takes the shortest
232       match as the length and the latter the longest  match.   Hence  in  the
233       former  case  a  *  at the end is redundant while in the latter case it
234       matches the whole remainder of the string.  This does  not  affect  the
235       result  of the single subscript case as here the length of the match is
236       irrelevant.
237
238   Array Element Assignment
239       A subscript may be used on the left side of an assignment like so:
240
241              name[exp]=value
242
243       In this form of assignment the element or range specified by exp is re‐
244       placed by the expression on the right side.  An array (but not an asso‐
245       ciative array) may be created by assignment to a range or element.  Ar‐
246       rays do not nest, so assigning a parenthesized list of values to an el‐
247       ement or range changes the number of elements in  the  array,  shifting
248       the  other  elements  to accommodate the new values.  (This is not sup‐
249       ported for associative arrays.)
250
251       This syntax also works as an argument to the typeset command:
252
253              typeset "name[exp]"=value
254
255       The value may not be a parenthesized list in this case; only single-el‐
256       ement  assignments may be made with typeset.  Note that quotes are nec‐
257       essary in this case to prevent the brackets from being  interpreted  as
258       filename generation operators.  The noglob precommand modifier could be
259       used instead.
260
261       To delete an element of an ordinary array, assign `()' to that element.
262       To delete an element of an associative array, use the unset command:
263
264              unset "name[exp]"
265
266   Subscript Flags
267       If  the  opening bracket, or the comma in a range, in any subscript ex‐
268       pression is directly followed by an opening parenthesis, the string  up
269       to  the matching closing one is considered to be a list of flags, as in
270       `name[(flags)exp]'.
271
272       The flags s, n and b take an argument; the delimiter is shown below  as
273       `:',  but  any  character,  or  the  matching  pairs  `(...)', `{...}',
274       `[...]', or `<...>', may be used, but note that  `<...>'  can  only  be
275       used if the subscript is inside a double quoted expression or a parame‐
276       ter substitution enclosed in braces as otherwise the expression is  in‐
277       terpreted as a redirection.
278
279       The flags currently understood are:
280
281       w      If  the  parameter  subscripted is a scalar then this flag makes
282              subscripting work on words instead of characters.   The  default
283              word  separator  is  whitespace.   When combined with the i or I
284              flag, the effect is to produce the index of the first  character
285              of  the  first/last  word  which matches the given pattern; note
286              that a failed match in this case always yields 0.
287
288       s:string:
289              This gives the string that separates words (for use with  the  w
290              flag).  The delimiter character : is arbitrary; see above.
291
292       p      Recognize  the same escape sequences as the print builtin in the
293              string argument of a subsequent `s' flag.
294
295       f      If the parameter subscripted is a scalar then  this  flag  makes
296              subscripting work on lines instead of characters, i.e. with ele‐
297              ments separated by newlines.  This is a shorthand for `pws:\n:'.
298
299       r      Reverse subscripting: if this flag is given, the exp is taken as
300              a  pattern  and  the result is the first matching array element,
301              substring or word (if the parameter is an  array,  if  it  is  a
302              scalar,  or if it is a scalar and the `w' flag is given, respec‐
303              tively).  The subscript used is the number of the matching  ele‐
304              ment,  so  that  pairs of subscripts such as `$foo[(r)??,3]' and
305              `$foo[(r)??,(r)f*]' are possible if the parameter is not an  as‐
306              sociative array.  If the parameter is an associative array, only
307              the value part of each pair is compared to the pattern, and  the
308              result is that value.
309
310              If  a  search  through an ordinary array failed, the search sets
311              the subscript to one past the end of the array, and hence  ${ar‐
312              ray[(r)pattern]}  will  substitute  the  empty string.  Thus the
313              success of a search can be tested by using the (i) flag, for ex‐
314              ample (assuming the option KSH_ARRAYS is not in effect):
315
316                     [[ ${array[(i)pattern]} -le ${#array} ]]
317
318              If KSH_ARRAYS is in effect, the -le should be replaced by -lt.
319
320       R      Like  `r',  but  gives  the last match.  For associative arrays,
321              gives all possible matches. May be used for assigning  to  ordi‐
322              nary  array  elements,  but not for assigning to associative ar‐
323              rays.  On failure, for normal arrays this has the effect of  re‐
324              turning  the element corresponding to subscript 0; this is empty
325              unless one of the options KSH_ARRAYS or KSH_ZERO_SUBSCRIPT is in
326              effect.
327
328              Note that in subscripts with both `r' and `R' pattern characters
329              are active even if they were substituted for  a  parameter  (re‐
330              gardless  of  the setting of GLOB_SUBST which controls this fea‐
331              ture in normal pattern matching).  The flag `e' can be added  to
332              inhibit  pattern  matching.  As this flag does not inhibit other
333              forms of substitution, care is still required; using a parameter
334              to hold the key has the desired effect:
335
336                     key2='original key'
337                     print ${array[(Re)$key2]}
338
339       i      Like `r', but gives the index of the match instead; this may not
340              be combined with a second argument.  On the left side of an  as‐
341              signment,  behaves  like  `r'.   For associative arrays, the key
342              part of each pair is compared to  the  pattern,  and  the  first
343              matching  key  found  is the result.  On failure substitutes the
344              length of the array plus one, as discussed under the description
345              of `r', or the empty string for an associative array.
346
347       I      Like `i', but gives the index of the last match, or all possible
348              matching keys in an associative array.  On  failure  substitutes
349              0,  or  the empty string for an associative array.  This flag is
350              best when testing for values or keys that do not exist.
351
352       k      If used in a subscript on an associative array, this flag causes
353              the  keys  to  be interpreted as patterns, and returns the value
354              for the first key found where exp is matched by the  key.   Note
355              this  could be any such key as no ordering of associative arrays
356              is defined.  This flag does not work on the left side of an  as‐
357              signment  to  an  associative array element.  If used on another
358              type of parameter, this behaves like `r'.
359
360       K      On an associative array this is like `k' but returns all  values
361              where  exp is matched by the keys.  On other types of parameters
362              this has the same effect as `R'.
363
364       n:expr:
365              If combined with `r', `R', `i' or `I', makes them give  the  nth
366              or  nth  last  match (if expr evaluates to n).  This flag is ig‐
367              nored when the array is associative.  The delimiter character  :
368              is arbitrary; see above.
369
370       b:expr:
371              If  combined  with `r', `R', `i' or `I', makes them begin at the
372              nth or nth last element, word, or character (if  expr  evaluates
373              to n).  This flag is ignored when the array is associative.  The
374              delimiter character : is arbitrary; see above.
375
376       e      This flag causes any pattern matching that would be performed on
377              the  subscript  to  use  plain  string  matching instead.  Hence
378              `${array[(re)*]}' matches only the array element whose value  is
379              *.  Note that other forms of substitution such as parameter sub‐
380              stitution are not inhibited.
381
382              This flag can also be used to force * or @ to be interpreted  as
383              a  single  key rather than as a reference to all values.  It may
384              be used for either purpose on the left side of an assignment.
385
386       See Parameter Expansion Flags (zshexpn(1)) for additional ways  to  ma‐
387       nipulate the results of array subscripting.
388
389   Subscript Parsing
390       This  discussion applies mainly to associative array key strings and to
391       patterns used for reverse subscripting (the `r', `R', `i', etc. flags),
392       but  it  may also affect parameter substitutions that appear as part of
393       an arithmetic expression in an ordinary subscript.
394
395       To avoid subscript parsing limitations in  assignments  to  associative
396       array elements, use the append syntax:
397
398              aa+=('key with "*strange*" characters' 'value string')
399
400       The  basic rule to remember when writing a subscript expression is that
401       all text between the opening `[' and the closing `]' is interpreted  as
402       if  it  were in double quotes (see zshmisc(1)).  However, unlike double
403       quotes which normally cannot nest, subscript expressions may appear in‐
404       side  double-quoted  strings  or inside other subscript expressions (or
405       both!), so the rules have two important differences.
406
407       The first difference is that brackets (`[' and `]') must appear as bal‐
408       anced  pairs  in  a  subscript expression unless they are preceded by a
409       backslash (`\').  Therefore, within a subscript expression (and  unlike
410       true  double-quoting) the sequence `\[' becomes `[', and similarly `\]'
411       becomes `]'.  This applies even in cases where a backslash is not  nor‐
412       mally required; for example, the pattern `[^[]' (to match any character
413       other than an open bracket) should be written `[^\[]' in a reverse-sub‐
414       script pattern.  However, note that `\[^\[\]' and even `\[^[]' mean the
415       same thing, because backslashes are always stripped  when  they  appear
416       before brackets!
417
418       The  same rule applies to parentheses (`(' and `)') and braces (`{' and
419       `}'): they must appear either in balanced pairs or preceded by a  back‐
420       slash,  and  backslashes that protect parentheses or braces are removed
421       during parsing.  This is because parameter expansions may be surrounded
422       by  balanced  braces,  and  subscript  flags are introduced by balanced
423       parentheses.
424
425       The second difference is that a double-quote (`"') may appear  as  part
426       of  a  subscript  expression without being preceded by a backslash, and
427       therefore that the two characters `\"' remain as two characters in  the
428       subscript (in true double-quoting, `\"' becomes `"').  However, because
429       of the standard shell quoting rules, any double-quotes that appear must
430       occur  in balanced pairs unless preceded by a backslash.  This makes it
431       more difficult to write a subscript expression  that  contains  an  odd
432       number  of  double-quote characters, but the reason for this difference
433       is so that  when  a  subscript  expression  appears  inside  true  dou‐
434       ble-quotes, one can still write `\"' (rather than `\\\"') for `"'.
435
436       To  use  an  odd number of double quotes as a key in an assignment, use
437       the typeset builtin and an enclosing pair of double quotes; to refer to
438       the value of that key, again use double quotes:
439
440              typeset -A aa
441              typeset "aa[one\"two\"three\"quotes]"=QQQ
442              print "$aa[one\"two\"three\"quotes]"
443
444       It is important to note that the quoting rules do not change when a pa‐
445       rameter expansion with a subscript is nested inside  another  subscript
446       expression.  That is, it is not necessary to use additional backslashes
447       within the inner subscript expression; they are removed only once, from
448       the  innermost  subscript  outwards.  Parameters are also expanded from
449       the innermost subscript first, as each expansion is encountered left to
450       right in the outer expression.
451
452       A  further complication arises from a way in which subscript parsing is
453       not different from double quote parsing.  As  in  true  double-quoting,
454       the  sequences `\*', and `\@' remain as two characters when they appear
455       in a subscript expression.  To use a literal `*' or `@' as an  associa‐
456       tive array key, the `e' flag must be used:
457
458              typeset -A aa
459              aa[(e)*]=star
460              print $aa[(e)*]
461
462       A  last  detail  must  be  considered when reverse subscripting is per‐
463       formed.  Parameters appearing in the subscript expression are first ex‐
464       panded  and  then  the complete expression is interpreted as a pattern.
465       This has two effects: first, parameters behave as if GLOB_SUBST were on
466       (and  it  cannot  be  turned  off); second, backslashes are interpreted
467       twice, once when parsing the array subscript and again when parsing the
468       pattern.   In  a  reverse  subscript,  it's necessary to use four back‐
469       slashes to cause a single backslash to match literally in the  pattern.
470       For complex patterns, it is often easiest to assign the desired pattern
471       to a parameter and then refer to that parameter in the  subscript,  be‐
472       cause  then the backslashes, brackets, parentheses, etc., are seen only
473       when the complete expression is converted to a pattern.  To  match  the
474       value of a parameter literally in a reverse subscript, rather than as a
475       pattern, use `${(q)name}' (see zshexpn(1)) to quote the expanded value.
476
477       Note that the `k' and `K' flags are reverse subscripting for  an  ordi‐
478       nary  array, but are not reverse subscripting for an associative array!
479       (For an associative array, the keys in the array itself are interpreted
480       as  patterns  by  those  flags; the subscript is a plain string in that
481       case.)
482
483       One final note, not directly related to subscripting: the numeric names
484       of positional parameters (described below) are parsed specially, so for
485       example `$2foo' is equivalent to `${2}foo'.   Therefore,  to  use  sub‐
486       script  syntax  to extract a substring from a positional parameter, the
487       expansion must be surrounded by braces; for example, `${2[3,5]}' evalu‐
488       ates to the third through fifth characters of the second positional pa‐
489       rameter, but `$2[3,5]' is the entire second parameter concatenated with
490       the filename generation pattern `[3,5]'.
491

POSITIONAL PARAMETERS

493       The  positional parameters provide access to the command-line arguments
494       of a shell function, shell script, or the shell itself; see the section
495       `Invocation', and also the section `Functions'.  The parameter n, where
496       n is a number, is the nth positional parameter.  The parameter `$0'  is
497       a special case, see the section `Parameters Set By The Shell'.
498
499       The  parameters  *, @ and argv are arrays containing all the positional
500       parameters; thus `$argv[n]', etc., is equivalent to simply `$n'.   Note
501       that the options KSH_ARRAYS or KSH_ZERO_SUBSCRIPT apply to these arrays
502       as well, so with either of those options set, `${argv[0]}'  is  equiva‐
503       lent to `$1' and so on.
504
505       Positional parameters may be changed after the shell or function starts
506       by using the set builtin, by assigning to the argv array, or by  direct
507       assignment  of  the  form  `n=value' where n is the number of the posi‐
508       tional parameter to be changed.  This also creates (with empty  values)
509       any of the positions from 1 to n that do not already have values.  Note
510       that, because the positional parameters form an array, an array assign‐
511       ment  of  the  form  `n=(value  ...)' is allowed, and has the effect of
512       shifting all the values at positions greater than n by  as  many  posi‐
513       tions as necessary to accommodate the new values.
514

LOCAL PARAMETERS

516       Shell function executions delimit scopes for shell parameters.  (Param‐
517       eters are dynamically scoped.)  The typeset builtin, and  its  alterna‐
518       tive  forms  declare, integer, local and readonly (but not export), can
519       be used to declare a parameter as being local to the innermost scope.
520
521       When a parameter is read or assigned to, the innermost existing parame‐
522       ter  of  that  name  is  used.  (That is, the local parameter hides any
523       less-local parameter.)  However, assigning to a non-existent parameter,
524       or  declaring  a  new parameter with export, causes it to be created in
525       the outermost scope.
526
527       Local parameters disappear when their scope ends.  unset can be used to
528       delete  a  parameter while it is still in scope; any outer parameter of
529       the same name remains hidden.
530
531       Special parameters may also be made local; they  retain  their  special
532       attributes  unless  either  the existing or the newly-created parameter
533       has the -h (hide) attribute.  This may have unexpected  effects:  there
534       is  no  default  value,  so  if there is no assignment at the point the
535       variable is made local, it will be set to an empty value  (or  zero  in
536       the case of integers).  The following:
537
538              typeset PATH=/new/directory:$PATH
539
540       is  valid  for temporarily allowing the shell or programmes called from
541       it to find the programs in /new/directory inside a function.
542
543       Note that the restriction in older versions of zsh that  local  parame‐
544       ters were never exported has been removed.
545

PARAMETERS SET BY THE SHELL

547       In  the  parameter lists that follow, the mark `<S>' indicates that the
548       parameter is special.  `<Z>' indicates that the parameter does not  ex‐
549       ist when the shell initializes in sh or ksh emulation mode.
550
551       The following parameters are automatically set by the shell:
552
553       ! <S>  The  process  ID  of  the last command started in the background
554              with &, put into the background with the bg builtin, or  spawned
555              with coproc.
556
557       # <S>  The  number of positional parameters in decimal.  Note that some
558              confusion may occur with the syntax  $#param  which  substitutes
559              the  length of param.  Use ${#} to resolve ambiguities.  In par‐
560              ticular, the sequence `$#-...' in an  arithmetic  expression  is
561              interpreted as the length of the parameter -, q.v.
562
563       ARGC <S> <Z>
564              Same as #.
565
566       $ <S>  The  process  ID  of  this  shell.  Note that this indicates the
567              original shell started by invoking  zsh;  all  processes  forked
568              from  the  shells  without executing a new program, such as sub‐
569              shells started by (...), substitute the same value.
570
571       - <S>  Flags supplied to the shell on invocation or by the set  or  se‐
572              topt commands.
573
574       * <S>  An array containing the positional parameters.
575
576       argv <S> <Z>
577              Same  as  *.  Assigning to argv changes the local positional pa‐
578              rameters, but argv is not itself a  local  parameter.   Deleting
579              argv  with unset in any function deletes it everywhere, although
580              only the innermost positional parameter array is deleted  (so  *
581              and @ in other scopes are not affected).
582
583       @ <S>  Same as argv[@], even when argv is not set.
584
585       ? <S>  The exit status returned by the last command.
586
587       0 <S>  The  name  used to invoke the current shell, or as set by the -c
588              command line option upon invocation.   If  the  FUNCTION_ARGZERO
589              option  is  set, $0 is set upon entry to a shell function to the
590              name of the function, and upon entry to a sourced script to  the
591              name  of  the  script,  and reset to its previous value when the
592              function or script returns.
593
594       status <S> <Z>
595              Same as ?.
596
597       pipestatus <S> <Z>
598              An array containing the exit statuses returned by  all  commands
599              in the last pipeline.
600
601       _ <S>  The last argument of the previous command.  Also, this parameter
602              is set in the environment of every command executed to the  full
603              pathname of the command.
604
605       CPUTYPE
606              The machine type (microprocessor class or machine model), as de‐
607              termined at run time.
608
609       EGID <S>
610              The effective group ID of the shell process.  If you have suffi‐
611              cient  privileges,  you may change the effective group ID of the
612              shell process by assigning to this  parameter.   Also  (assuming
613              sufficient  privileges),  you  may start a single command with a
614              different effective group ID by `(EGID=gid; command)'
615
616              If this is made local, it is not implicitly set to 0, but may be
617              explicitly set locally.
618
619       EUID <S>
620              The  effective user ID of the shell process.  If you have suffi‐
621              cient privileges, you may change the effective user  ID  of  the
622              shell  process  by  assigning to this parameter.  Also (assuming
623              sufficient privileges), you may start a single  command  with  a
624              different effective user ID by `(EUID=uid; command)'
625
626              If this is made local, it is not implicitly set to 0, but may be
627              explicitly set locally.
628
629       ERRNO <S>
630              The value of errno (see errno(3)) as set by  the  most  recently
631              failed  system  call.  This value is system dependent and is in‐
632              tended for debugging purposes.   It  is  also  useful  with  the
633              zsh/system  module  which  allows the number to be turned into a
634              name or message.
635
636       FUNCNEST <S>
637              Integer.  If greater than or equal to zero, the maximum  nesting
638              depth  of  shell  functions.   When  it is exceeded, an error is
639              raised at the point where a function  is  called.   The  default
640              value  is  determined when the shell is configured, but is typi‐
641              cally 500.  Increasing the value increases the danger of a  run‐
642              away  function  recursion causing the shell to crash.  Setting a
643              negative value turns off the check.
644
645       GID <S>
646              The real group ID of the shell process.  If you have  sufficient
647              privileges,  you may change the group ID of the shell process by
648              assigning to this parameter.  Also (assuming  sufficient  privi‐
649              leges),  you  may start a single command under a different group
650              ID by `(GID=gid; command)'
651
652              If this is made local, it is not implicitly set to 0, but may be
653              explicitly set locally.
654
655       HISTCMD
656              The  current  history  event  number in an interactive shell, in
657              other words  the  event  number  for  the  command  that  caused
658              $HISTCMD  to be read.  If the current history event modifies the
659              history, HISTCMD changes to the new maximum history  event  num‐
660              ber.
661
662       HOST   The current hostname.
663
664       LINENO <S>
665              The  line  number of the current line within the current script,
666              sourced file, or shell function being  executed,  whichever  was
667              started most recently.  Note that in the case of shell functions
668              the line number refers to the function as  it  appeared  in  the
669              original  definition,  not necessarily as displayed by the func‐
670              tions builtin.
671
672       LOGNAME
673              If the corresponding variable is not set in the  environment  of
674              the  shell, it is initialized to the login name corresponding to
675              the current login session. This parameter is exported by default
676              but  this  can be disabled using the typeset builtin.  The value
677              is set to the string returned by the getlogin(3) system call  if
678              that is available.
679
680       MACHTYPE
681              The machine type (microprocessor class or machine model), as de‐
682              termined at compile time.
683
684       OLDPWD The previous working directory.  This is set when the shell ini‐
685              tializes and whenever the directory changes.
686
687       OPTARG <S>
688              The  value  of the last option argument processed by the getopts
689              command.
690
691       OPTIND <S>
692              The index of the last option argument processed by  the  getopts
693              command.
694
695       OSTYPE The operating system, as determined at compile time.
696
697       PPID <S>
698              The process ID of the parent of the shell.  As for $$, the value
699              indicates the parent of the original shell and does  not  change
700              in subshells.
701
702       PWD    The  present working directory.  This is set when the shell ini‐
703              tializes and whenever the directory changes.
704
705       RANDOM <S>
706              A pseudo-random integer from 0 to 32767,  newly  generated  each
707              time  this parameter is referenced.  The random number generator
708              can be seeded by assigning a numeric value to RANDOM.
709
710              The  values   of   RANDOM   form   an   intentionally-repeatable
711              pseudo-random sequence; subshells that reference RANDOM will re‐
712              sult in identical pseudo-random values unless the value of  RAN‐
713              DOM  is referenced or seeded in the parent shell in between sub‐
714              shell invocations.
715
716       SECONDS <S>
717              The number of seconds since shell invocation.  If this parameter
718              is assigned a value, then the value returned upon reference will
719              be the value that was assigned plus the number of seconds  since
720              the assignment.
721
722              Unlike other special parameters, the type of the SECONDS parame‐
723              ter can be changed using the typeset command.  Only integer  and
724              one  of  the  floating  point  types  are allowed.  For example,
725              `typeset -F SECONDS' causes the value to be reported as a float‐
726              ing  point  number.  The value is available to microsecond accu‐
727              racy, although the shell may show more or fewer digits depending
728              on  the  use  of typeset.  See the documentation for the builtin
729              typeset in zshbuiltins(1) for more details.
730
731       SHLVL <S>
732              Incremented by one each time a new shell is started.
733
734       signals
735              An array containing the names of the signals.   Note  that  with
736              the standard zsh numbering of array indices, where the first el‐
737              ement has index 1, the signals are offset by 1 from  the  signal
738              number  used  by  the operating system.  For example, on typical
739              Unix-like systems HUP is signal number 1, but is referred to  as
740              $signals[2].   This  is because of EXIT at position 1 in the ar‐
741              ray, which is used internally by zsh but is not known to the op‐
742              erating system.
743
744       TRY_BLOCK_ERROR <S>
745              In an always block, indicates whether the preceding list of code
746              caused an error.  The value is 1 to indicate an error, 0  other‐
747              wise.   It may be reset, clearing the error condition.  See Com‐
748              plex Commands in zshmisc(1)
749
750       TRY_BLOCK_INTERRUPT <S>
751              This variable works in a similar  way  to  TRY_BLOCK_ERROR,  but
752              represents  the  status  of an interrupt from the signal SIGINT,
753              which typically comes from the keyboard when the user types  ^C.
754              If  set  to  0, any such interrupt will be reset; otherwise, the
755              interrupt is propagated after the always block.
756
757              Note that it is possible that an interrupt  arrives  during  the
758              execution  of  the  always  block; this interrupt is also propa‐
759              gated.
760
761       TTY    The name of the tty associated with the shell, if any.
762
763       TTYIDLE <S>
764              The idle time of the tty associated with the shell in seconds or
765              -1 if there is no such tty.
766
767       UID <S>
768              The  real  user ID of the shell process.  If you have sufficient
769              privileges, you may change the user ID of the shell by assigning
770              to  this  parameter.  Also (assuming sufficient privileges), you
771              may start  a  single  command  under  a  different  user  ID  by
772              `(UID=uid; command)'
773
774              If this is made local, it is not implicitly set to 0, but may be
775              explicitly set locally.
776
777       USERNAME <S>
778              The username corresponding to the real  user  ID  of  the  shell
779              process.   If you have sufficient privileges, you may change the
780              username (and also the user ID and group ID) of the shell by as‐
781              signing  to  this  parameter.   Also (assuming sufficient privi‐
782              leges), you may start a single command under a  different  user‐
783              name  (and  user  ID  and group ID) by `(USERNAME=username; com‐
784              mand)'
785
786       VENDOR The vendor, as determined at compile time.
787
788       zsh_eval_context <S> <Z> (ZSH_EVAL_CONTEXT <S>)
789              An array (colon-separated list) indicating the context of  shell
790              code that is being run.  Each time a piece of shell code that is
791              stored within the shell is executed a string is temporarily  ap‐
792              pended  to  the  array to indicate the type of operation that is
793              being performed.  Read in order the array gives an indication of
794              the  stack of operations being performed with the most immediate
795              context last.
796
797              Note that the variable does not give  information  on  syntactic
798              context  such  as  pipelines or subshells.  Use $ZSH_SUBSHELL to
799              detect subshells.
800
801              The context is one of the following:
802              cmdarg Code specified by the -c option to the command line  that
803                     invoked the shell.
804
805              cmdsubst
806                     Command substitution using the `...` or $(...) construct.
807
808              equalsubst
809                     File substitution using the =(...) construct.
810
811              eval   Code executed by the eval builtin.
812
813              evalautofunc
814                     Code executed with the KSH_AUTOLOAD mechanism in order to
815                     define an autoloaded function.
816
817              fc     Code from the shell history executed by the -e option  to
818                     the fc builtin.
819
820              file   Lines  of code being read directly from a file, for exam‐
821                     ple by the source builtin.
822
823              filecode
824                     Lines of code being read from a .zwc file instead of  di‐
825                     rectly from the source file.
826
827              globqual
828                     Code executed by the e or + glob qualifier.
829
830              globsort
831                     Code executed to order files by the o glob qualifier.
832
833              insubst
834                     File substitution using the <(...) construct.
835
836              loadautofunc
837                     Code  read  directly  from a file to define an autoloaded
838                     function.
839
840              outsubst
841                     File substitution using the >(...) construct.
842
843              sched  Code executed by the sched builtin.
844
845              shfunc A shell function.
846
847              stty   Code passed to stty by  the  STTY  environment  variable.
848                     Normally  this  is  passed  directly to the system's stty
849                     command, so this value is unlikely to be  seen  in  prac‐
850                     tice.
851
852              style  Code  executed as part of a style retrieved by the zstyle
853                     builtin from the zsh/zutil module.
854
855              toplevel
856                     The highest execution level of a  script  or  interactive
857                     shell.
858
859              trap   Code  executed  as  a  trap  defined by the trap builtin.
860                     Traps defined as functions have the context  shfunc.   As
861                     traps  are asynchronous they may have a different hierar‐
862                     chy from other code.
863
864              zpty   Code executed by the zpty builtin from the zsh/zpty  mod‐
865                     ule.
866
867              zregexparse-guard
868                     Code  executed as a guard by the zregexparse command from
869                     the zsh/zutil module.
870
871              zregexparse-action
872                     Code executed as an action  by  the  zregexparse  command
873                     from the zsh/zutil module.
874
875       ZSH_ARGZERO
876              If  zsh  was  invoked  to  run a script, this is the name of the
877              script.  Otherwise, it is the name used to  invoke  the  current
878              shell.    This  is  the  same  as  the  value  of  $0  when  the
879              POSIX_ARGZERO option is set, but is always available.
880
881       ZSH_EXECUTION_STRING
882              If the shell was started with the option -c, this  contains  the
883              argument passed to the option.  Otherwise it is not set.
884
885       ZSH_NAME
886              Expands  to  the basename of the command used to invoke this in‐
887              stance of zsh.
888
889       ZSH_PATCHLEVEL
890              The output of `git describe --tags --long' for the  zsh  reposi‐
891              tory  used  to build the shell.  This is most useful in order to
892              keep track of versions of the shell during  development  between
893              releases;  hence most users should not use it and should instead
894              rely on $ZSH_VERSION.
895
896       zsh_scheduled_events
897              See the section `The zsh/sched Module' in zshmodules(1).
898
899       ZSH_SCRIPT
900              If zsh was invoked to run a script, this  is  the  name  of  the
901              script, otherwise it is unset.
902
903       ZSH_SUBSHELL
904              Readonly  integer.   Initially  zero,  incremented each time the
905              shell forks to create a  subshell  for  executing  code.   Hence
906              `(print  $ZSH_SUBSHELL)' and `print $(print $ZSH_SUBSHELL)' out‐
907              put 1, while `( (print $ZSH_SUBSHELL) )' outputs 2.
908
909       ZSH_VERSION
910              The version number of the release of zsh.
911

PARAMETERS USED BY THE SHELL

913       The following parameters are used by the shell.  Again, `<S>' indicates
914       that  the  parameter  is special and `<Z>' indicates that the parameter
915       does not exist when the shell initializes in sh or ksh emulation mode.
916
917       In cases where there are two parameters with an  upper-  and  lowercase
918       form  of the same name, such as path and PATH, the lowercase form is an
919       array and the uppercase form is a scalar with the elements of the array
920       joined  together  by colons.  These are similar to tied parameters cre‐
921       ated via `typeset -T'.  The normal use for the colon-separated form  is
922       for exporting to the environment, while the array form is easier to ma‐
923       nipulate within the shell.  Note that unsetting either of the pair will
924       unset  the  other; they retain their special properties when recreated,
925       and recreating one of the pair will recreate the other.
926
927       ARGV0  If exported, its value is used as the argv[0] of  external  com‐
928              mands.  Usually used in constructs like `ARGV0=emacs nethack'.
929
930       BAUD   The  rate in bits per second at which data reaches the terminal.
931              The line editor will use this value in order to compensate for a
932              slow  terminal  by  delaying updates to the display until neces‐
933              sary.  If the parameter is unset or the value is zero  the  com‐
934              pensation  mechanism is turned off.  The parameter is not set by
935              default.
936
937              This parameter may be profitably set in some circumstances, e.g.
938              for  slow  modems  dialing into a communications server, or on a
939              slow wide area network.  It should be set to the  baud  rate  of
940              the slowest part of the link for best performance.
941
942       cdpath <S> <Z> (CDPATH <S>)
943              An  array  (colon-separated  list) of directories specifying the
944              search path for the cd command.
945
946       COLUMNS <S>
947              The number of columns  for  this  terminal  session.   Used  for
948              printing select lists and for the line editor.
949
950       CORRECT_IGNORE
951              If set, is treated as a pattern during spelling correction.  Any
952              potential correction that matches the pattern is  ignored.   For
953              example,  if the value is `_*' then completion functions (which,
954              by convention, have names beginning with `_') will never be  of‐
955              fered  as  spelling  corrections.  The pattern does not apply to
956              the correction of file names, as applied by the CORRECT_ALL  op‐
957              tion (so with the example just given files beginning with `_' in
958              the current directory would still be completed).
959
960       CORRECT_IGNORE_FILE
961              If set, is treated as a pattern during  spelling  correction  of
962              file names.  Any file name that matches the pattern is never of‐
963              fered as a correction.  For example, if the value is  `.*'  then
964              dot  file  names  will never be offered as spelling corrections.
965              This is useful with the CORRECT_ALL option.
966
967       DIRSTACKSIZE
968              The maximum size of the directory stack, by default there is  no
969              limit.  If the stack gets larger than this, it will be truncated
970              automatically.  This is useful with the AUTO_PUSHD option.
971
972       ENV    If the ENV environment variable is set when zsh is invoked as sh
973              or ksh, $ENV is sourced after the profile scripts.  The value of
974              ENV is subjected to parameter expansion,  command  substitution,
975              and arithmetic expansion before being interpreted as a pathname.
976              Note that ENV is not used unless the shell  is  interactive  and
977              zsh is emulating sh or ksh.
978
979       FCEDIT The  default  editor  for the fc builtin.  If FCEDIT is not set,
980              the parameter EDITOR is used; if  that  is  not  set  either,  a
981              builtin default, usually vi, is used.
982
983       fignore <S> <Z> (FIGNORE <S>)
984              An array (colon separated list) containing the suffixes of files
985              to be ignored during filename completion.  However,  if  comple‐
986              tion only generates files with suffixes in this list, then these
987              files are completed anyway.
988
989       fpath <S> <Z> (FPATH <S>)
990              An array (colon separated list) of  directories  specifying  the
991              search  path  for  function  definitions.  This path is searched
992              when a function with the -u attribute is referenced.  If an exe‐
993              cutable  file is found, then it is read and executed in the cur‐
994              rent environment.
995
996       histchars <S>
997              Three characters used by the shell's history and lexical  analy‐
998              sis  mechanism.  The first character signals the start of a his‐
999              tory expansion (default `!').  The second character signals  the
1000              start  of a quick history substitution (default `^').  The third
1001              character is the comment character (default `#').
1002
1003              The characters must be in the ASCII character set;  any  attempt
1004              to  set  histchars to characters with a locale-dependent meaning
1005              will be rejected with an error message.
1006
1007       HISTCHARS <S> <Z>
1008              Same as histchars.  (Deprecated.)
1009
1010       HISTFILE
1011              The file to save the history in when an interactive shell exits.
1012              If unset, the history is not saved.
1013
1014       HISTORY_IGNORE
1015              If  set,  is  treated as a pattern at the time history files are
1016              written.  Any potential history entry that matches  the  pattern
1017              is  skipped.   For example, if the value is `fc *' then commands
1018              that invoke the interactive history editor are never written  to
1019              the history file.
1020
1021              Note  that  HISTORY_IGNORE  defines a single pattern: to specify
1022              alternatives use the `(first|second|...)' syntax.
1023
1024              Compare the HIST_NO_STORE option or the zshaddhistory hook,  ei‐
1025              ther  of  which  would prevent such commands from being added to
1026              the interactive history at all.  If you wish to use  HISTORY_IG‐
1027              NORE to stop history being added in the first place, you can de‐
1028              fine the following hook:
1029
1030                     zshaddhistory() {
1031                       emulate -L zsh
1032                       ## uncomment if HISTORY_IGNORE
1033                       ## should use EXTENDED_GLOB syntax
1034                       # setopt extendedglob
1035                       [[ $1 != ${~HISTORY_IGNORE} ]]
1036                     }
1037
1038       HISTSIZE <S>
1039              The maximum number of events  stored  in  the  internal  history
1040              list.   If  you  use  the HIST_EXPIRE_DUPS_FIRST option, setting
1041              this value larger than the SAVEHIST size will give you the  dif‐
1042              ference as a cushion for saving duplicated history events.
1043
1044              If this is made local, it is not implicitly set to 0, but may be
1045              explicitly set locally.
1046
1047       HOME <S>
1048              The default argument for the cd command.  This is not set  auto‐
1049              matically  by  the  shell in sh, ksh or csh emulation, but it is
1050              typically present in the environment anyway, and if  it  becomes
1051              set it has its usual special behaviour.
1052
1053       IFS <S>
1054              Internal  field  separators  (by default space, tab, newline and
1055              NUL), that are used to separate words which result from  command
1056              or  parameter expansion and words read by the read builtin.  Any
1057              characters from the set space, tab and newline  that  appear  in
1058              the IFS are called IFS white space.  One or more IFS white space
1059              characters or one non-IFS white space  character  together  with
1060              any  adjacent  IFS white space character delimit a field.  If an
1061              IFS white space character appears  twice  consecutively  in  the
1062              IFS,  this  character  is treated as if it were not an IFS white
1063              space character.
1064
1065              If the parameter is unset, the default is used.  Note this has a
1066              different effect from setting the parameter to an empty string.
1067
1068       KEYBOARD_HACK
1069              This  variable defines a character to be removed from the end of
1070              the command line  before  interpreting  it  (interactive  shells
1071              only). It is intended to fix the problem with keys placed annoy‐
1072              ingly close to return and replaces  the  SUNKEYBOARDHACK  option
1073              which did this for backquotes only.  Should the chosen character
1074              be one of singlequote, doublequote or backquote, there must also
1075              be an odd number of them on the command line for the last one to
1076              be removed.
1077
1078              For backward compatibility, if the SUNKEYBOARDHACK option is ex‐
1079              plicitly  set,  the value of KEYBOARD_HACK reverts to backquote.
1080              If the option is explicitly  unset,  this  variable  is  set  to
1081              empty.
1082
1083       KEYTIMEOUT
1084              The  time the shell waits, in hundredths of seconds, for another
1085              key to be pressed when reading bound multi-character sequences.
1086
1087       LANG <S>
1088              This variable determines the locale category  for  any  category
1089              not specifically selected via a variable starting with `LC_'.
1090
1091       LC_ALL <S>
1092              This variable overrides the value of the `LANG' variable and the
1093              value of any of the other variables starting with `LC_'.
1094
1095       LC_COLLATE <S>
1096              This variable determines the locale category for character  col‐
1097              lation  information within ranges in glob brackets and for sort‐
1098              ing.
1099
1100       LC_CTYPE <S>
1101              This variable determines the locale category for character  han‐
1102              dling  functions.   If  the  MULTIBYTE  option is in effect this
1103              variable or LANG should contain a value that reflects the  char‐
1104              acter set in use, even if it is a single-byte character set, un‐
1105              less only the 7-bit subset (ASCII) is used.  For example, if the
1106              character   set   is  ISO-8859-1,  a  suitable  value  might  be
1107              en_US.iso88591 (certain Linux distributions) or  en_US.ISO8859-1
1108              (MacOS).
1109
1110       LC_MESSAGES <S>
1111              This  variable  determines the language in which messages should
1112              be written.  Note that zsh does not use message catalogs.
1113
1114       LC_NUMERIC <S>
1115              This variable affects the decimal point character and  thousands
1116              separator character for the formatted input/output functions and
1117              string conversion functions.  Note that zsh ignores this setting
1118              when parsing floating point mathematical expressions.
1119
1120       LC_TIME <S>
1121              This  variable  determines the locale category for date and time
1122              formatting in prompt escape sequences.
1123
1124       LINES <S>
1125              The number of lines for this terminal session.  Used for  print‐
1126              ing select lists and for the line editor.
1127
1128       LISTMAX
1129              In the line editor, the number of matches to list without asking
1130              first. If the value is negative, the list will be  shown  if  it
1131              spans  at most as many lines as given by the absolute value.  If
1132              set to zero, the shell asks only if the top of the listing would
1133              scroll off the screen.
1134
1135       LOGCHECK
1136              The interval in seconds between checks for login/logout activity
1137              using the watch parameter.
1138
1139       MAIL   If this parameter is set and mailpath  is  not  set,  the  shell
1140              looks for mail in the specified file.
1141
1142       MAILCHECK
1143              The interval in seconds between checks for new mail.
1144
1145       mailpath <S> <Z> (MAILPATH <S>)
1146              An  array  (colon-separated  list) of filenames to check for new
1147              mail.  Each filename can be followed by a `?' and a message that
1148              will  be printed.  The message will undergo parameter expansion,
1149              command substitution and arithmetic expansion with the  variable
1150              $_  defined  as  the name of the file that has changed.  The de‐
1151              fault message is `You have new mail'.  If an element is a direc‐
1152              tory  instead  of  a file the shell will recursively check every
1153              file in every subdirectory of the element.
1154
1155       manpath <S> <Z> (MANPATH <S> <Z>)
1156              An array (colon-separated list) whose value is not used  by  the
1157              shell.   The manpath array can be useful, however, since setting
1158              it also sets MANPATH, and vice versa.
1159
1160       match
1161       mbegin
1162       mend   Arrays set by the shell when the b globbing flag is used in pat‐
1163              tern matches.  See the subsection Globbing flags in the documen‐
1164              tation for Filename Generation in zshexpn(1).
1165
1166       MATCH
1167       MBEGIN
1168       MEND   Set by the shell when the m globbing flag  is  used  in  pattern
1169              matches.  See the subsection Globbing flags in the documentation
1170              for Filename Generation in zshexpn(1).
1171
1172       module_path <S> <Z> (MODULE_PATH <S>)
1173              An array (colon-separated list)  of  directories  that  zmodload
1174              searches  for dynamically loadable modules.  This is initialized
1175              to a standard  pathname,  usually  `/usr/local/lib/zsh/$ZSH_VER‐
1176              SION'.   (The  `/usr/local/lib' part varies from installation to
1177              installation.)  For security reasons, any value set in the envi‐
1178              ronment when the shell is started will be ignored.
1179
1180              These parameters only exist if the installation supports dynamic
1181              module loading.
1182
1183       NULLCMD <S>
1184              The command name to assume if a redirection is specified with no
1185              command.   Defaults to cat.  For sh/ksh behavior, change this to
1186              :.  For csh-like behavior, unset this parameter; the shell  will
1187              print an error message if null commands are entered.
1188
1189       path <S> <Z> (PATH <S>)
1190              An  array  (colon-separated  list)  of directories to search for
1191              commands.  When this parameter is set, each directory is scanned
1192              and all files found are put in a hash table.
1193
1194       POSTEDIT <S>
1195              This  string  is output whenever the line editor exits.  It usu‐
1196              ally contains termcap strings to reset the terminal.
1197
1198       PROMPT <S> <Z>
1199       PROMPT2 <S> <Z>
1200       PROMPT3 <S> <Z>
1201       PROMPT4 <S> <Z>
1202              Same as PS1, PS2, PS3 and PS4, respectively.
1203
1204       prompt <S> <Z>
1205              Same as PS1.
1206
1207       PROMPT_EOL_MARK
1208              When  the  PROMPT_CR  and  PROMPT_SP  options   are   set,   the
1209              PROMPT_EOL_MARK  parameter  can be used to customize how the end
1210              of partial lines are shown.  This parameter undergoes prompt ex‐
1211              pansion,  with  the  PROMPT_PERCENT option set.  If not set, the
1212              default behavior is equivalent to the value `%B%S%#%s%b'.
1213
1214       PS1 <S>
1215              The primary prompt string, printed before a command is read.  It
1216              undergoes  a  special  form of expansion before being displayed;
1217              see EXPANSION OF PROMPT SEQUENCES in zshmisc(1).  The default is
1218              `%m%# '.
1219
1220       PS2 <S>
1221              The secondary prompt, printed when the shell needs more informa‐
1222              tion to complete a command.  It is expanded in the same  way  as
1223              PS1.  The default is `%_> ', which displays any shell constructs
1224              or quotation marks which are currently being processed.
1225
1226       PS3 <S>
1227              Selection prompt used within a select loop.  It is  expanded  in
1228              the same way as PS1.  The default is `?# '.
1229
1230       PS4 <S>
1231              The  execution  trace prompt.  Default is `+%N:%i> ', which dis‐
1232              plays the name of the current shell structure and the line  num‐
1233              ber within it.  In sh or ksh emulation, the default is `+ '.
1234
1235       psvar <S> <Z> (PSVAR <S>)
1236              An  array  (colon-separated  list) whose elements can be used in
1237              PROMPT strings.  Setting psvar also sets PSVAR, and vice versa.
1238
1239       READNULLCMD <S>
1240              The command name to assume if  a  single  input  redirection  is
1241              specified with no command.  Defaults to more.
1242
1243       REPORTMEMORY
1244              If   nonnegative,  commands  whose  maximum  resident  set  size
1245              (roughly speaking, main memory usage) in  kilobytes  is  greater
1246              than  this  value  have  timing statistics reported.  The format
1247              used to output statistics is the value of the TIMEFMT parameter,
1248              which  is  the  same as for the REPORTTIME variable and the time
1249              builtin; note that by default this does not output memory usage.
1250              Appending  "  max  RSS  %M" to the value of TIMEFMT causes it to
1251              output the value that triggered the report.   If  REPORTTIME  is
1252              also  in  use, at most a single report is printed for both trig‐
1253              gers.  This feature requires the getrusage() system  call,  com‐
1254              monly supported by modern Unix-like systems.
1255
1256       REPORTTIME
1257              If  nonnegative,  commands whose combined user and system execu‐
1258              tion times (measured in seconds) are  greater  than  this  value
1259              have  timing  statistics printed for them.  Output is suppressed
1260              for commands executed within the line editor, including  comple‐
1261              tion;  commands  explicitly  marked  with the time keyword still
1262              cause the summary to be printed in this case.
1263
1264       REPLY  This parameter is reserved by convention to pass  string  values
1265              between  shell  scripts and shell builtins in situations where a
1266              function call or redirection are impossible or undesirable.  The
1267              read  builtin  and the select complex command may set REPLY, and
1268              filename generation both sets and examines its value when evalu‐
1269              ating  certain  expressions.  Some modules also employ REPLY for
1270              similar purposes.
1271
1272       reply  As REPLY, but for array values rather than strings.
1273
1274       RPROMPT <S>
1275       RPS1 <S>
1276              This prompt is displayed on the right-hand side  of  the  screen
1277              when  the  primary  prompt is being displayed on the left.  This
1278              does not work if the SINGLE_LINE_ZLE option is set.  It  is  ex‐
1279              panded in the same way as PS1.
1280
1281       RPROMPT2 <S>
1282       RPS2 <S>
1283              This  prompt  is  displayed on the right-hand side of the screen
1284              when the secondary prompt is being displayed on the left.   This
1285              does  not  work if the SINGLE_LINE_ZLE option is set.  It is ex‐
1286              panded in the same way as PS2.
1287
1288       SAVEHIST
1289              The maximum number of history events  to  save  in  the  history
1290              file.
1291
1292              If this is made local, it is not implicitly set to 0, but may be
1293              explicitly set locally.
1294
1295       SPROMPT <S>
1296              The prompt used for spelling correction.  The sequence `%R'  ex‐
1297              pands  to the string which presumably needs spelling correction,
1298              and `%r' expands to the proposed correction.  All  other  prompt
1299              escapes are also allowed.
1300
1301              The actions available at the prompt are [nyae]:
1302              n (`no') (default)
1303                     Discard the correction and run the command.
1304              y (`yes')
1305                     Make the correction and run the command.
1306              a (`abort')
1307                     Discard the entire command line without running it.
1308              e (`edit')
1309                     Resume editing the command line.
1310
1311       STTY   If  this  parameter is set in a command's environment, the shell
1312              runs the stty command with the value of this parameter as  argu‐
1313              ments  in order to set up the terminal before executing the com‐
1314              mand. The modes apply only to the command, and are reset when it
1315              finishes  or  is suspended. If the command is suspended and con‐
1316              tinued later with the fg or wait builtins it will see the  modes
1317              specified  by  STTY,  as if it were not suspended.  This (inten‐
1318              tionally) does not apply if the command is continued  via  `kill
1319              -CONT'.   STTY  is  ignored  if  the command is run in the back‐
1320              ground, or if it is in the environment of the shell but not  ex‐
1321              plicitly assigned to in the input line. This avoids running stty
1322              at every external command by  accidentally  exporting  it.  Also
1323              note  that  STTY  should  not be used for window size specifica‐
1324              tions; these will not be local to the command.
1325
1326       TERM <S>
1327              The type of terminal in use.  This is used when looking up term‐
1328              cap  sequences.  An assignment to TERM causes zsh to re-initial‐
1329              ize the terminal, even if  the  value  does  not  change  (e.g.,
1330              `TERM=$TERM').   It is necessary to make such an assignment upon
1331              any change to the terminal definition database or terminal  type
1332              in order for the new settings to take effect.
1333
1334       TERMINFO <S>
1335              A  reference  to  your terminfo database, used by the `terminfo'
1336              library when the system has it; see terminfo(5).  If  set,  this
1337              causes  the shell to reinitialise the terminal, making the work‐
1338              around `TERM=$TERM' unnecessary.
1339
1340       TERMINFO_DIRS <S>
1341              A colon-seprarated list of terminfo databases, used by the `ter‐
1342              minfo'  library  when  the  system has it; see terminfo(5). This
1343              variable is only used by certain terminal libraries, in particu‐
1344              lar  ncurses;  see  terminfo(5) to check support on your system.
1345              If set, this causes the shell to reinitialise the terminal, mak‐
1346              ing  the  workaround `TERM=$TERM' unnecessary.  Note that unlike
1347              other colon-separated arrays this is not tied to a zsh array.
1348
1349       TIMEFMT
1350              The format of process time reports with the time  keyword.   The
1351              default is `%J  %U user %S system %P cpu %*E total'.  Recognizes
1352              the following escape sequences, although not all may  be  avail‐
1353              able on all systems, and some that are available may not be use‐
1354              ful:
1355
1356              %%     A `%'.
1357              %U     CPU seconds spent in user mode.
1358              %S     CPU seconds spent in kernel mode.
1359              %E     Elapsed time in seconds.
1360              %P     The CPU percentage, computed as 100*(%U+%S)/%E.
1361              %W     Number of times the process was swapped.
1362              %X     The average amount in (shared) text space used  in  kilo‐
1363                     bytes.
1364              %D     The average amount in (unshared) data/stack space used in
1365                     kilobytes.
1366              %K     The total space used (%X+%D) in kilobytes.
1367              %M     The  maximum memory the process had in use at any time in
1368                     kilobytes.
1369              %F     The  number  of  major  page  faults  (page  needed to be
1370                     brought from disk).
1371              %R     The number of minor page faults.
1372              %I     The number of input operations.
1373              %O     The number of output operations.
1374              %r     The number of socket messages received.
1375              %s     The number of socket messages sent.
1376              %k     The number of signals received.
1377              %w     Number of voluntary context switches (waits).
1378              %c     Number of involuntary context switches.
1379              %J     The name of this job.
1380
1381              A star may be inserted between the percent sign and flags print‐
1382              ing  time  (e.g.,  `%*E'); this causes the time to be printed in
1383              `hh:mm:ss.ttt' format (hours and minutes  are  only  printed  if
1384              they  are  not  zero).   Alternatively,  `m'  or `u' may be used
1385              (e.g., `%mE') to produce time  output  in  milliseconds  or  mi‐
1386              croseconds, respectively.
1387
1388       TMOUT  If  this  parameter  is  nonzero, the shell will receive an ALRM
1389              signal if a command is not entered within the  specified  number
1390              of  seconds  after  issuing  a  prompt.  If  there  is a trap on
1391              SIGALRM, it will be executed and a new alarm is scheduled  using
1392              the  value  of the TMOUT parameter after executing the trap.  If
1393              no trap is set, and the idle time of the terminal  is  not  less
1394              than  the  value of the TMOUT parameter, zsh terminates.  Other‐
1395              wise a new alarm is scheduled to TMOUT seconds  after  the  last
1396              keypress.
1397
1398       TMPPREFIX
1399              A  pathname  prefix  which  the shell will use for all temporary
1400              files.  Note that this should include an initial  part  for  the
1401              file  name  as  well  as  any  directory  names.  The default is
1402              `/tmp/zsh'.
1403
1404       TMPSUFFIX
1405              A filename suffix which the shell will use for  temporary  files
1406              created  by  process substitutions (e.g., `=(list)').  Note that
1407              the value should include a leading dot `.' if intended to be in‐
1408              terpreted as a file extension.  The default is not to append any
1409              suffix, thus this parameter should be assigned only when  needed
1410              and then unset again.
1411
1412       watch <S> <Z> (WATCH <S>)
1413              An  array  (colon-separated  list) of login/logout events to re‐
1414              port.
1415
1416              If it contains the single  word  `all',  then  all  login/logout
1417              events  are  reported.   If it contains the single word `notme',
1418              then all events are reported as with `all' except $USERNAME.
1419
1420              An entry in this list may consist of a username, an `@' followed
1421              by  a  remote hostname, and a `%' followed by a line (tty).  Any
1422              of these may be a pattern (be sure to quote this during the  as‐
1423              signment  to  watch so that it does not immediately perform file
1424              generation); the setting of  the  EXTENDED_GLOB  option  is  re‐
1425              spected.   Any  or  all of these components may be present in an
1426              entry; if a login/logout event matches all of them,  it  is  re‐
1427              ported.
1428
1429              For example, with the EXTENDED_GLOB option set, the following:
1430
1431                     watch=('^(pws|barts)')
1432
1433              causes  reports for activity associated with any user other than
1434              pws or barts.
1435
1436       WATCHFMT
1437              The format of login/logout reports if  the  watch  parameter  is
1438              set.  Default is `%n has %a %l from %m'.  Recognizes the follow‐
1439              ing escape sequences:
1440
1441              %n     The name of the user that logged in/out.
1442
1443              %a     The observed action, i.e. "logged on" or "logged off".
1444
1445              %l     The line (tty) the user is logged in on.
1446
1447              %M     The full hostname of the remote host.
1448
1449              %m     The hostname up to the first `.'.  If only the IP address
1450                     is  available  or  the utmp field contains the name of an
1451                     X-windows display, the whole name is printed.
1452
1453                     NOTE: The `%m' and `%M' escapes will work only  if  there
1454                     is a host name field in the utmp on your machine.  Other‐
1455                     wise they are treated as ordinary strings.
1456
1457              %S (%s)
1458                     Start (stop) standout mode.
1459
1460              %U (%u)
1461                     Start (stop) underline mode.
1462
1463              %B (%b)
1464                     Start (stop) boldface mode.
1465
1466              %t
1467              %@     The time, in 12-hour, am/pm format.
1468
1469              %T     The time, in 24-hour format.
1470
1471              %w     The date in `day-dd' format.
1472
1473              %W     The date in `mm/dd/yy' format.
1474
1475              %D     The date in `yy-mm-dd' format.
1476
1477              %D{string}
1478                     The date formatted as string using the strftime function,
1479                     with  zsh  extensions as described by EXPANSION OF PROMPT
1480                     SEQUENCES in zshmisc(1).
1481
1482              %(x:true-text:false-text)
1483                     Specifies a ternary expression.  The character  following
1484                     the  x  is arbitrary; the same character is used to sepa‐
1485                     rate the text for the "true" result  from  that  for  the
1486                     "false"  result.  Both the separator and the right paren‐
1487                     thesis may be escaped with a backslash.  Ternary  expres‐
1488                     sions may be nested.
1489
1490                     The  test  character x may be any one of `l', `n', `m' or
1491                     `M', which indicate a `true' result if the  corresponding
1492                     escape sequence would return a non-empty value; or it may
1493                     be `a', which indicates a `true' result  if  the  watched
1494                     user  has  logged  in,  or  `false' if he has logged out.
1495                     Other characters evaluate to neither true nor false;  the
1496                     entire expression is omitted in this case.
1497
1498                     If  the result is `true', then the true-text is formatted
1499                     according  to  the  rules  above  and  printed,  and  the
1500                     false-text  is  skipped.   If  `false',  the true-text is
1501                     skipped and the false-text is formatted and printed.  Ei‐
1502                     ther or both of the branches may be empty, but both sepa‐
1503                     rators must be present in any case.
1504
1505       WORDCHARS <S>
1506              A list of non-alphanumeric characters considered part of a  word
1507              by the line editor.
1508
1509       ZBEEP  If set, this gives a string of characters, which can use all the
1510              same codes as the bindkey command as described  in  the  zsh/zle
1511              module entry in zshmodules(1), that will be output to the termi‐
1512              nal instead of beeping.  This may have a visible instead  of  an
1513              audible  effect;  for  example,  the  string `\e[?5h\e[?5l' on a
1514              vt100 or xterm will have the effect of flashing reverse video on
1515              and  off  (if  you usually use reverse video, you should use the
1516              string `\e[?5l\e[?5h' instead).  This takes precedence over  the
1517              NOBEEP option.
1518
1519       ZDOTDIR
1520              The  directory  to search for shell startup files (.zshrc, etc),
1521              if not $HOME.
1522
1523       zle_bracketed_paste
1524              Many terminal emulators have a feature that allows  applications
1525              to  identify  when  text is pasted into the terminal rather than
1526              being typed normally. For ZLE, this means that  special  charac‐
1527              ters such as tabs and newlines can be inserted instead of invok‐
1528              ing editor commands.  Furthermore, pasted text  forms  a  single
1529              undo event and if the region is active, pasted text will replace
1530              the region.
1531
1532              This two-element array contains the  terminal  escape  sequences
1533              for  enabling  and disabling the feature. These escape sequences
1534              are used to enable bracketed paste when ZLE is active  and  dis‐
1535              able  it at other times.  Unsetting the parameter has the effect
1536              of ensuring that bracketed paste remains disabled.
1537
1538       zle_highlight
1539              An array describing contexts in which ZLE should  highlight  the
1540              input text.  See Character Highlighting in zshzle(1).
1541
1542       ZLE_LINE_ABORTED
1543              This  parameter  is set by the line editor when an error occurs.
1544              It contains the line that was being edited at the point  of  the
1545              error.   `print -zr -- $ZLE_LINE_ABORTED' can be used to recover
1546              the line.  Only the most recent line of this kind is remembered.
1547
1548       ZLE_REMOVE_SUFFIX_CHARS
1549       ZLE_SPACE_SUFFIX_CHARS
1550              These parameters are used by the line editor.  In  certain  cir‐
1551              cumstances suffixes (typically space or slash) added by the com‐
1552              pletion system will be removed automatically, either because the
1553              next editing command was not an insertable character, or because
1554              the character was marked as requiring the suffix to be removed.
1555
1556              These variables can contain the sets  of  characters  that  will
1557              cause  the  suffix to be removed.  If ZLE_REMOVE_SUFFIX_CHARS is
1558              set, those characters will cause the suffix to  be  removed;  if
1559              ZLE_SPACE_SUFFIX_CHARS  is  set, those characters will cause the
1560              suffix to be removed and replaced by a space.
1561
1562              If ZLE_REMOVE_SUFFIX_CHARS is not set, the default behaviour  is
1563              equivalent to:
1564
1565                     ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&|'
1566
1567              If  ZLE_REMOVE_SUFFIX_CHARS  is  set but is empty, no characters
1568              have this behaviour.  ZLE_SPACE_SUFFIX_CHARS  takes  precedence,
1569              so that the following:
1570
1571                     ZLE_SPACE_SUFFIX_CHARS=$'&|'
1572
1573              causes  the  characters  `&' and `|' to remove the suffix but to
1574              replace it with a space.
1575
1576              To illustrate the difference, suppose that the  option  AUTO_RE‐
1577              MOVE_SLASH is in effect and the directory DIR has just been com‐
1578              pleted, with an appended /, following which the user types  `&'.
1579              The  default result is `DIR&'.  With ZLE_REMOVE_SUFFIX_CHARS set
1580              but  without  including  `&'  the  result  is   `DIR/&'.    With
1581              ZLE_SPACE_SUFFIX_CHARS set to include `&' the result is `DIR &'.
1582
1583              Note  that  certain completions may provide their own suffix re‐
1584              moval or replacement behaviour which overrides  the  values  de‐
1585              scribed  here.   See the completion system documentation in zsh‐
1586              compsys(1).
1587
1588       ZLE_RPROMPT_INDENT <S>
1589              If set, used to give the indentation between the right hand side
1590              of  the  right  prompt  in  the  line editor as given by RPS1 or
1591              RPROMPT and the right hand side of the screen.  If not set,  the
1592              value 1 is used.
1593
1594              Typically  this  will  be used to set the value to 0 so that the
1595              prompt appears flush with the right hand  side  of  the  screen.
1596              This  is  not  the  default as many terminals do not handle this
1597              correctly, in particular when the prompt appears at the  extreme
1598              bottom  right  of the screen.  Recent virtual terminals are more
1599              likely to handle this case correctly.  Some  experimentation  is
1600              necessary.
1601
1602
1603
1604zsh 5.8.1                      February 12, 2022                   ZSHPARAM(1)
Impressum