diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2000-04-01 20:43:43 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2000-04-01 20:43:43 +0000 |
commit | e025336f2f6d9f107ee1e03b9900f04af0544ba9 (patch) | |
tree | 37b0ce74587d42d4bcb024991526d2361fcdf04a /Doc/Zsh/params.yo | |
parent | 20c5fbe688f24010c578c48d4b4d228f0e1a56c3 (diff) | |
download | zsh-e025336f2f6d9f107ee1e03b9900f04af0544ba9.tar.gz zsh-e025336f2f6d9f107ee1e03b9900f04af0544ba9.tar.xz zsh-e025336f2f6d9f107ee1e03b9900f04af0544ba9.zip |
Updated from list as far as 10376
Diffstat (limited to 'Doc/Zsh/params.yo')
-rw-r--r-- | Doc/Zsh/params.yo | 269 |
1 files changed, 197 insertions, 72 deletions
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index 4c25a18ef..c6571f38f 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -7,7 +7,8 @@ A name may be any sequence of alphanumeric characters and underscores, or the single characters `tt(*)', `tt(@)', `tt(#)', `tt(?)', `tt(-)', `tt($)', or `tt(!)'. The value may be a em(scalar) (a string), -an integer, or an array. +an integer, an array (indexed numerically), or an em(associative) +array (an unordered set of name-value pairs, indexed by name). To assign a scalar or integer value to a parameter, use the tt(typeset) builtin. findex(typeset, use of) @@ -15,45 +16,41 @@ To assign an array value, use `tt(set -A) var(name) var(value) ...'. findex(set, use of) The value of a parameter may also be assigned by writing: -nofill(var(name)tt(=)var(value)) +indent(var(name)tt(=)var(value)) -If the integer attribute, tt(-i), is set for var(name), -the var(value) is subject to arithmetic evaluation. +If the integer attribute, tt(-i), is set for var(name), the var(value) +is subject to arithmetic evaluation. See noderef(Array Parameters) +for additional forms of assignment. -In the parameter lists, the mark `<S>' indicates that the parameter is special. +In the parameter lists that follow, the mark `<S>' indicates that the +parameter is special. Special parameters cannot have their type changed, and they stay special even if unset. `<Z>' indicates that the parameter does not exist when the shell -initialises in tt(sh) or tt(ksh) emulation mode. +initializes in tt(sh) or tt(ksh) emulation mode. startmenu() -menu(Local Parameters) menu(Array Parameters) menu(Positional Parameters) +menu(Local Parameters) menu(Parameters Set By The Shell) menu(Parameters Used By The Shell) endmenu() -texinode(Local Parameters)(Array Parameters)()(Parameters) -sect(Local Parameters) -Shell function executions delimit scopes for shell parameters. -(Parameters are dynamically scoped.) The tt(typeset) builtin, and its -alternative forms tt(declare), tt(integer), tt(local) and tt(readonly) -(but not tt(export)), can be used to declare a parameter as being local -to the innermost scope. - -When a parameter is read or assigned to, the -innermost existing parameter of that name is used. (That is, the -local parameter hides any less-local parameter.) However, assigning -to a non-existent parameter, or declaring a new parameter with tt(export), -causes it to be created in the em(outer)most scope. - -Local parameters disappear when their scope ends. -tt(unset) can be used to delete a parameter while it is still in scope; this -will reveal the next outer parameter of the same name. However, em(special) -parameters are still special when unset. -texinode(Array Parameters)(Positional Parameters)(Local Parameters)(Parameters) +texinode(Array Parameters)(Positional Parameters)()(Parameters) sect(Array Parameters) The value of an array parameter may be assigned by writing: -nofill(var(name)tt(=LPAR())var(value) ...tt(RPAR())) +indent(var(name)tt(=LPAR())var(value) ...tt(RPAR())) + +If no parameter var(name) exists, an ordinary array parameter is created. +Associative arrays must be declared first, by `tt(typeset -A) var(name)'. +When var(name) refers to an associative array, the parenthesized list is +interpreted as alternating keys and values: + +indent(var(name)tt(=LPAR())var(key) var(value) ...tt(RPAR())) + +Every var(key) must have a var(value) in this case. To create an empty +array or associative array, use: + +indent(var(name)tt(=LPAR()RPAR())) Individual elements of an array may be selected using a subscript. A subscript of the form `tt([)var(exp)tt(])' @@ -62,8 +59,12 @@ an arithmetic expression which will be subject to arithmetic expansion as if it were surrounded by `tt($LPAR()LPAR())...tt(RPAR()RPAR())'. The elements are numbered beginning with 1 unless the tt(KSH_ARRAYS) option is set when they are numbered from zero. +cindex(subscripts) pindex(KSH_ARRAYS, use of) +The same subscripting syntax is used for associative arrays, +except that no arithmetic expansion is applied to var(exp). + A subscript of the form `tt([*])' or `tt([@])' evaluates to all elements of an array; there is no difference between the two except when they appear within double quotes. @@ -72,8 +73,8 @@ except when they appear within double quotes. A subscript of the form `tt([)var(exp1)tt(,)var(exp2)tt(])' selects all elements in the range var(exp1) to var(exp2), -inclusive. -If one of the subscripts evaluates to a negative number, +inclusive. (Associative arrays are unordered, and so do not support +ranges.) If one of the subscripts evaluates to a negative number, say tt(-)var(n), then the var(n)th element from the end of the array is used. Thus `tt($foo[-3])' is the third element from the end of the array tt(foo), and @@ -90,22 +91,29 @@ option is set, the braced form is the only one that will work, the subscript otherwise not being treated specially. If a subscript is used on the left side of an assignment the selected -range is replaced by the expression on the right side. +element or range is replaced by the expression on the right side. An +array (but not an associative array) may be created by assignment to a +range or element. Arrays do not nest, so assigning a parenthesized list +of values to an element or range changes the number of elements in the +array, shifting the other elements to accommodate the new values. (This +is not supported for associative arrays.) + +To delete an element of an ordinary array, assign `tt(LPAR()RPAR())' to +that element. +To delete an element of an associative array, use the tt(unset) command. If the opening bracket or the comma is directly followed by an opening parentheses the string up to the matching closing one is considered to be a list of flags. The flags currently understood are: startitem() -item(tt(e))( -this option has no effect and retained for backward compatibility only. -) item(tt(w))( -if the parameter subscripted is a scalar than this flag makes -subscription work on a per-word basis instead of characters. +If the parameter subscripted is a scalar than this flag makes +subscripting work on words instead of characters. The default word +separator is whitespace. ) item(tt(s:)var(string)tt(:))( -this gives the var(string) that separates words (for use with the +This gives the var(string) that separates words (for use with the tt(w) flag). ) item(tt(p))( @@ -113,44 +121,117 @@ Recognize the same escape sequences as the tt(print) builtin in the string argument of a subsequent `tt(s)' flag. ) item(tt(f))( -if the parameter subscripted is a scalar than this flag makes -subscription work on a per-line basis instead of characters. -This is a shorthand for `tt(pws:\n:)'. +If the parameter subscripted is a scalar than this flag makes +subscripting work on lines instead of characters, i.e. with elements +separated by newlines. This is a shorthand for `tt(pws:\n:)'. ) item(tt(r))( -if this flag is given the var(exp) is taken as a pattern and the -result is the first matching array element, substring or word (if the -parameter is an array, if it is a scalar, or if it is a scalar and the -`tt(w)' flag is given, respectively); note that this is like giving a -number: `tt($foo[(r))var(??)tt(,3])' and `tt($foo[(r))var(??)tt(,(r)f*])' work. +Reverse subscripting: if this flag is given, the var(exp) is taken as a +pattern and the result is the first matching array element, substring or +word (if the parameter is an array, if it is a scalar, or if it is a scalar +and the `tt(w)' flag is given, respectively). The subscript used is the +number of the matching element, so that pairs of subscripts such as +`tt($foo[(r))var(??)tt(,3])' and `tt($foo[(r))var(??)tt(,(r)f*])' +are possible. If the parameter is an associative array, only the value part +of each pair is compared to the pattern. ) item(tt(R))( -like `tt(r)', but gives the last match. +Like `tt(r)', but gives the last match. For associative arrays, gives +all possible matches. +) +item(tt(k))( +If used in a subscript on a parameter that is not an associative +array, this behaves like `tt(r)', but if used on an association, it +makes the keys be interpreted as patterns and returns the first value +whose key matches the var(exp). +) +item(tt(K))( +On an associtation this is like `tt(k)' but returns all values whose +keys match the var(exp). On other types of parameters this has the +same effect as `tt(R)'. ) item(tt(i))( like `tt(r)', but gives the index of the match instead; this may not -be combined with a second argument. +be combined with a second argument. For associative arrays, the key +part of each pair is compared to the pattern, and the first matching +key found is used. ) item(tt(I))( -like `tt(i), but gives the index of the last match. +like `tt(i)', but gives the index of the last match, or all possible +matching keys in an associative array. ) item(tt(n:)var(expr)tt(:))( if combined with `tt(r)', `tt(R)', `tt(i)' or `tt(I)', makes them give the var(n)th or var(n)th last match (if var(expr) evaluates to -var(n)). +var(n)). This flag is ignored when the array is associative. +) +item(tt(b:)var(expr)tt(:))( +if combined with `tt(r)', `tt(R)', `tt(i)' or `tt(I)', makes them begin +at the var(n)th or var(n)th last element, word, or character (if var(expr) +evaluates to var(n)). This flag is ignored when the array is associative. +) +item(tt(e))( +This option has no effect and retained for backward compatibility only. ) enditem() -texinode(Positional Parameters)(Parameters Set By The Shell)(Array Parameters)(Parameters) +texinode(Positional Parameters)(Local Parameters)(Array Parameters)(Parameters) sect(Positional Parameters) -Positional parameters are set by the shell on invocation, -by the tt(set) builtin, or by direct assignment. +The positional parameters provide access to the command-line arguments +of a shell function, shell script, or the shell itself; see +noderef(Invocation), and also noderef(Functions). The parameter var(n), where var(n) is a number, is the var(n)th positional parameter. The parameters tt(*), tt(@) and tt(argv) are arrays containing all the positional parameters; thus `tt($argv[)var(n)tt(])', etc., is equivalent to simply `tt($)var(n)'. -texinode(Parameters Set By The Shell)(Parameters Used By The Shell)(Positional Parameters)(Parameters) +Positional parameters may be changed after the shell or function starts by +using the tt(set) builtin, by assigning to the tt(argv) array, or by direct +assignment of the form `var(n)tt(=)var(value)' where var(n) is the number of +the positional parameter to be changed. This also creates (with empty +values) any of the positions from 1 to var(n) that do not already have +values. Note that, because the positional parameters form an array, an +array assignment of the form `var(n)tt(=LPAR())var(value) ...tt(RPAR())' is +allowed, and has the effect of shifting all the values at positions greater +than var(n) by as many positions as necessary to accommodate the new values. + +texinode(Local Parameters)(Parameters Set By The Shell)(Positional Parameters)(Parameters) +sect(Local Parameters) +Shell function executions delimit scopes for shell parameters. +(Parameters are dynamically scoped.) The tt(typeset) builtin, and its +alternative forms tt(declare), tt(integer), tt(local) and tt(readonly) +(but not tt(export)), can be used to declare a parameter as being local +to the innermost scope. + +When a parameter is read or assigned to, the +innermost existing parameter of that name is used. (That is, the +local parameter hides any less-local parameter.) However, assigning +to a non-existent parameter, or declaring a new parameter with tt(export), +causes it to be created in the em(outer)most scope. + +Local parameters disappear when their scope ends. +tt(unset) can be used to delete a parameter while it is still in scope; +any outer parameter of the same name remains hidden. + +Special parameters may also be made local; they retain their special +attributes unless either the existing or the newly-created parameter +has the tt(-h) (hide) attribute. This may have unexpected effects. +Firstly, there is no default value, so if there is no assigment at the +point the variable is made local, it will be set to an empty value (or zero +in the case of integers). Secondly, special parameters which are made +local will not be exported (as with other parameters), so that the global +value of the parameter remains present in the environment if it is already +there. This should be particularly noted in the case of tt(PATH): the +shell will use the local version of tt(PATH) for finding programmes, but +programmes using the shell's environment will inherit the global version. +The following: + +example(typeset PATH=/new/directory:$PATH) + +is valid for temporarily allowing the shell to find the programs in +tt(/new/directory) inside a function. + +texinode(Parameters Set By The Shell)(Parameters Used By The Shell)(Local Parameters)(Parameters) sect(Parameters Set By The Shell) The following parameters are automatically set by the shell: @@ -182,11 +263,15 @@ An array containing the positional parameters. ) vindex(argv) item(tt(argv) <S> <Z>)( -Same as tt(*). +Same as tt(*). Assigning to tt(argv) changes the local positional +parameters, but tt(argv) is em(not) itself a local parameter. +Deleting tt(argv) with tt(unset) in any function deletes it everywhere, +although only the innermost positional parameter array is deleted (so +tt(*) and tt(@) in other scopes are not affected). ) vindex(@) item(tt(@) <S>)( -Same as tt(argv[@]). +Same as tt(argv[@]), even when tt(argv) is not set. ) vindex(?) item(tt(?) <S>)( @@ -202,12 +287,22 @@ vindex(status) item(tt(status) <S> <Z>)( Same as tt(?). ) +vindex(pipestatus) +item(tt(pipestatus) <S> <Z>)( +An array containing the exit values returned by all commands in the +last pipeline. +) vindex(_) item(tt(_) <S>)( The last argument of the previous command. Also, this parameter is set in the environment of every command executed to the full pathname of the command. ) +vindex(CPUTYPE) +item(tt(CPUTYPE))( +The machine type (microprocessor class or machine model), +as determined at run time. +) vindex(EGID) item(tt(EGID) <S>)( The effective group ID of the shell process. If you have sufficient @@ -245,8 +340,11 @@ The current hostname. ) vindex(LINENO) item(tt(LINENO) <S>)( -The line number of the current line within the current script -being executed. +The line number of the current line within the current script, sourced +file, or shell function being executed, whichever was started most +recently. Note that in the case of shell functions the line +number refers to the function as it appeared in the original definition, +not necesarily as displayed by the tt(functions) builtin. ) vindex(LOGNAME) item(tt(LOGNAME))( @@ -262,7 +360,7 @@ as determined at compile time. ) vindex(OLDPWD) item(tt(OLDPWD))( -The previous working directory. This is set when the shell initialises +The previous working directory. This is set when the shell initializes and whenever the directory changes. ) vindex(OPTARG) @@ -285,7 +383,7 @@ The process ID of the parent of the shell. ) vindex(PWD) item(tt(PWD))( -The present working directory. This is set when the shell initialises +The present working directory. This is set when the shell initializes and whenever the directory changes. ) vindex(RANDOM) @@ -356,7 +454,7 @@ The following parameters are used by the shell: startitem() vindex(ARGV0) item(tt(ARGV0))( -If exported, its value is used as tt(argv[0]) of external commands. +If exported, its value is used as the tt(argv[0]) of external commands. Usually used in constructs like `tt(ARGV0=emacs nethack)'. ) vindex(BAUD) @@ -417,7 +515,7 @@ vindex(histchars) item(tt(histchars) <S>)( Three characters used by the shell's history and lexical analysis mechanism. The first character signals the start of a history -substitution (default `tt(!)'). The second character signals the +expansion (default `tt(!)'). The second character signals the start of a quick history substitution (default `tt(^)'). The third character is the comment character (default `tt(#)'). ) @@ -432,7 +530,10 @@ If unset, the history is not saved. ) vindex(HISTSIZE) item(tt(HISTSIZE) <S>)( -The maximum size of the history list. +The maximum number of events stored in the internal history list. +If you use the tt(HIST_EXPIRE_DUPS_FIRST) option, setting this value +larger than the tt(SAVEHIST) size will give you the difference as a +cushion for saving duplicated history events. ) vindex(HOME) item(tt(HOME) <S>)( @@ -442,7 +543,7 @@ vindex(IFS) item(tt(IFS) <S>)( Internal field separators (by default space, tab, newline and NUL), that are used to separate words which result from -command or parameter substitution and words read by +command or parameter expansion and words read by the tt(read) builtin. Any characters from the set space, tab and newline that appear in the IFS are called em(IFS white space). One or more IFS white space characters or one non-IFS white space @@ -481,6 +582,13 @@ item(tt(LC_MESSAGES) <S>)( This variable determines the language in which messages should be written. Note that zsh does not use message catalogs. ) +vindex(LC_NUMERIC) +item(tt(LC_NUMERIC) <S>)( +This variable affects the decimal point character and thousands +separator character for the formatted input/output functions +and string conversion functions. Note that zsh ignores this +setting when parsing floating point mathematical expressions. +) vindex(LC_TIME) item(tt(LC_TIME) <S>)( This variable determines the locale category for date and time @@ -493,7 +601,9 @@ Used for printing select lists and for the line editor. ) vindex(LISTMAX) item(tt(LISTMAX))( -In the line editor, the number of filenames to list without asking first. +In the line editor, the number of matches to list without asking +first. If the value is negative, the list will be shown if it spans at +most as many lines as given by the absolute value. If set to zero, the shell asks only if the top of the listing would scroll off the screen. ) @@ -518,7 +628,7 @@ An array (colon-separated list) of filenames to check for new mail. Each filename can be followed by a `tt(?)' and a message that will be printed. The message will undergo parameter expansion, command substitution and arithmetic -substitution with the variable tt($_) defined as the name +expansion with the variable tt($_) defined as the name of the file that has changed. The default message is `tt(You have new mail)'. If an element is a directory instead of a file the shell will recursively check every @@ -538,7 +648,7 @@ item(tt(module_path) <S> <Z> (tt(MODULE_PATH) <S>))( An array (colon-separated list) of directories that tt(zmodload) searches for dynamically loadable modules. -This is initialised to a standard pathname, +This is initialized to a standard pathname, usually `tt(/usr/local/lib/zsh/$ZSH_VERSION)'. (The `tt(/usr/local/lib)' part varies from installation to installation.) For security reasons, any value set in the environment when the shell @@ -593,7 +703,9 @@ The default is `tt(?# )'. ) vindex(PS4) item(tt(PS4) <S>)( -The execution trace prompt. Default is `tt(PLUS() )'. +The execution trace prompt. Default is `tt(PLUS()%N:%i> )', which displays +the name of the current shell structure and the line number within it. +In sh or ksh emulation, the default is `tt(PLUS() )'. ) vindex(PROMPT) xitem(tt(PROMPT) <S> <Z>) @@ -656,12 +768,12 @@ set up the terminal before executing the command. The modes apply only to the command, and are reset when it finishes or is suspended. If the command is suspended and continued later with the tt(fg) or tt(wait) builtins it will see the modes specified by tt(STTY), as if it were not suspended. This -(intentionally) does not apply if the command is continued via `tt(kill -CONT)'. -tt(STTY) is ignored if the command is run in the background, or if it is in the -environment of the shell but not explicitly assigned to in the input line. This -avoids running stty at every external command by accidentally exporting it. -Also note that tt(STTY) should not be used for window size specifications; these -will not be local to the command. +(intentionally) does not apply if the command is continued via `tt(kill +-CONT)'. tt(STTY) is ignored if the command is run in the background, or +if it is in the environment of the shell but not explicitly assigned to in +the input line. This avoids running stty at every external command by +accidentally exporting it. Also note that tt(STTY) should not be used for +window size specifications; these will not be local to the command. ) vindex(TERM) item(tt(TERM) <S>)( @@ -804,6 +916,19 @@ item(tt(WORDCHARS) <S>)( A list of non-alphanumeric characters considered part of a word by the line editor. ) +vindex(ZBEEP) +item(tt(ZBEEP))( +If set, this gives a string of characters, which can use all the same codes +as the tt(bindkey) command as described in +ifzman(the zsh/zle module entry in zmanref(zshmodules))\ +ifnzman(noderef(The zsh/zle Module))\ +, that will be output to the terminal +instead of beeping. This may have a visible instead of an audible effect; +for example, the string `tt(\e[?5h\e[?5l)' on a vt100 or xterm will have +the effect of flashing reverse video on and off (if you usually use reverse +video, you should use the string `tt(\e[?5l\e[?5h)' instead). This takes +precedence over the tt(NOBEEP) option. +) vindex(ZDOTDIR) item(tt(ZDOTDIR))( The directory to search for shell startup files (.zshrc, etc), |