Manual Pages for UNIX Darwin command on man zshmisc
MyWebUniversity

Manual Pages for UNIX Darwin command on man zshmisc

ZSHMISC(1) ZSHMISC(1)

NAME

zshmisc - everything and then some

SSIIMMPPLLEE CCOOMMMMAANNDDSS && PPIIPPEELLIINNEESS

A simple command is a sequence of optional parameter assignments fol-

lowed by blank-separated words, with optional redirections inter-

spersed. The first word is the command to be executed, and the remain-

ing words, if any, are arguments to the command. If a command name is given, the parameter assignments modify the environment of the command when it is executed. The value of a simple command is its exit status, or 128 plus the signal number if terminated by a signal. For example, eecchhoo ffoooo is a simple command with arguments. A pipeline is either a simple command, or a sequence of two or more simple commands where each command is separated from the next by `||' or `||&&'. Where commands are separated by `||', the standard output of the first command is connected to the standard input of the next. `||&&' is shorthand for `22>>&&11 ||', which connects both the standard output and the standard error of the command to the standard input of the next. The

value of a pipeline is the value of the last command, unless the pipe-

line is preceded by `!!' in which case the value is the logical inverse of the value of the last command. For example, eecchhoo ffoooo || sseedd ''ss//ffoooo//bbaarr//'' is a pipeline, where the output (`ffoooo' plus a newline) of the first command will be passed to the input of the second. If a pipeline is preceded by `ccoopprroocc', it is executed as a coprocess; a

two-way pipe is established between it and the parent shell. The shell

can read from or write to the coprocess by means of the `>>&&pp' and `<<&&pp'

redirection operators or with `pprriinntt -pp' and `rreeaadd -pp'. A pipeline

cannot be preceded by both `ccoopprroocc' and `!!'. If job control is active,

the coprocess can be treated in other than input and output as an ordi-

nary background job. A sublist is either a single pipeline, or a sequence of two or more pipelines separated by `&&&&' or `||||'. If two pipelines are separated by `&&&&', the second pipeline is executed only if the first succeeds (returns a zero value). If two pipelines are separated by `||||', the second is executed only if the first fails (returns a nonzero value). Both operators have equal precedence and are left associative. The value of the sublist is the value of the last pipeline executed. For example, ddmmeessgg || ggrreepp ppaanniicc &&&& pprriinntt yyeess

is a sublist consisting of two pipelines, the second just a simple com-

mand which will be executed if and only if the ggrreepp command returns a zero value. If it does not, the value of the sublist is that return value, else it is the value returned by the pprriinntt (almost certainly zero). A list is a sequence of zero or more sublists, in which each sublist is terminated by `;;', `&&', `&&||', `&&!!', or a newline. This terminator may optionally be omitted from the last sublist in the list when the list

appears as a complex command inside `((...))' or `{{...}}'. When a sub-

list is terminated by `;;' or newline, the shell waits for it to finish before executing the next sublist. If a sublist is terminated by a `&&', `&&||', or `&&!!', the shell executes the last pipeline in it in the background, and does not wait for it to finish (note the difference from other shells which execute the whole sublist in the background). A backgrounded pipeline returns a status of zero.

More generally, a list can be seen as a set of any shell commands what-

soever, including the complex commands below; this is implied wherever

the word `list' appears in later descriptions. For example, the com-

mands in a shell function form a special sort of list. PPRREECCOOMMMMAANNDD MMOODDIIFFIIEERRSS A simple command may be preceded by a precommand modifier, which will alter how the command is interpreted. These modifiers are shell builtin commands with the exception of nnooccoorrrreecctt which is a reserved word.

- The command is executed with a `-' prepended to its aarrggvv[[00]]

string. nnoogglloobb Filename generation (globbing) is not performed on any of the words. nnooccoorrrreecctt Spelling correction is not done on any of the words. This must

appear before any other precommand modifier, as it is inter-

preted immediately, before any parsing is done. It has no

effect in non-interactive shells.

eexxeecc The command is executed in the parent shell without forking. ccoommmmaanndd The command word is taken to be the name of an external command, rather than a shell function or builtin. bbuuiillttiinn The command word is taken to be the name of a builtin command, rather than a shell function or external command. CCOOMMPPLLEEXX CCOOMMMMAANNDDSS A complex command in zsh is one of the following: iiff list tthheenn list [ eelliiff list tthheenn list ] ... [ eellssee list ] ffii The iiff list is executed, and if it returns a zero exit status, the tthheenn list is executed. Otherwise, the eelliiff list is executed and if its value is zero, the tthheenn list is executed. If each eelliiff list returns nonzero, the eellssee list is executed. ffoorr name ... [ iinn word ... ] term ddoo list ddoonnee where term is at least one newline or ;;. Expand the list of

words, and set the parameter name to each of them in turn, exe-

cuting list each time. If the iinn word is omitted, use the posi-

tional parameters instead of the words. More than one parameter name can appear before the list of words. If N names are given, then on each execution of the loop the next NN words are assigned to the corresponding parameters. If there are more names than remaining words, the remaining parameters are each set to the empty string. Execution of the loop ends when there is no remaining word to assign to the first name. It is only possible for iinn to appear as the first name in the list, else it will be treated as marking the end of the list. ffoorr (((( [expr1] ;; [expr2] ;; [expr3] )))) ddoo list ddoonnee

The arithmetic expression expr1 is evaluated first (see the sec-

tion `Arithmetic Evaluation'). The arithmetic expression expr2 is repeatedly evaluated until it evaluates to zero and when

non-zero, list is executed and the arithmetic expression expr3

evaluated. If any expression is omitted, then it behaves as if it evaluated to 1. wwhhiillee list ddoo list ddoonnee Execute the ddoo list as long as the wwhhiillee list returns a zero exit status. uunnttiill list ddoo list ddoonnee Execute the ddoo list as long as uunnttiill list returns a nonzero exit status. rreeppeeaatt word ddoo list ddoonnee word is expanded and treated as an arithmetic expression, which must evaluate to a number n. list is then executed n times. ccaassee word iinn [ [((] pattern [ || pattern ] ... )) list (;;;;|;;&&) ] ... eessaacc Execute the list associated with the first pattern that matches word, if any. The form of the patterns is the same as that used for filename generation. See the section `Filename Generation'. If the list that is executed is terminated with ;;&& rather than ;;;;, the following list is also executed. This continues until either a list is terminated with ;;;; or the eessaacc is reached. sseelleecctt name [ iinn word ... term ] ddoo list ddoonnee where term is one or more newline or ;; to terminate the words. Print the set of words, each preceded by a number. If the iinn word is omitted, use the positional parameters. The PPRROOMMPPTT33 prompt is printed and a line is read from the line editor if the shell is interactive and that is active, or else standard input. If this line consists of the number of one of the listed words, then the parameter name is set to the word corresponding to this number. If this line is empty, the selection list is printed again. Otherwise, the value of the parameter name is set to null. The contents of the line read from standard input is

saved in the parameter RREEPPLLYY. list is executed for each selec-

tion until a break or end-of-file is encountered.

(( list )) Execute list in a subshell. Traps set by the ttrraapp builtin are reset to their default values while executing list. {{ list }} Execute list.

{{ try-list }} aallwwaayyss {{ always-list }}

First execute try-list. Regardless of errors, or bbrreeaakk, ccoonn-

ttiinnuuee, or rreettuurrnn commands encountered within try-list, execute

always-list. Execution then continues from the result of the

execution of try-list; in other words, any error, or bbrreeaakk, ccoonn-

ttiinnuuee, or rreettuurrnn command is treated in the normal way, as if

always-list were not present. The two chunks of code are

referred to as the `try block' and the `always block'. Optional newlines or semicolons may appear after the aallwwaayyss; note, however, that they may not appear between the preceeding closing brace and the aallwwaayyss. An `error' in this context is a condition such as a syntax error

which causes the shell to abort execution of the current func-

tion, script, or list. Syntax errors encountered while the

shell is parsing the code do not cause the always-list to be

executed. For example, an erroneously constructed iiff block in

ttrryy-lliisstt would cause the shell to abort during parsing, so that

aallwwaayyss-lliisstt would not be executed, while an erroneous substitu-

tion such as $${{**ffoooo**}} would cause a run-time error, after which

aallwwaayyss-lliisstt would be executed.

An error condition can be tested and reset with the special

integer variable TTRRYYBBLLOOCCKKEERRRROORR. Outside an aallwwaayyss-lliisstt the

value is irrelevant, but it is initialised to -11. Inside

aallwwaayyss-lliisstt, the value is 1 if an error occurred in the

ttrryy-lliisstt, else 0. If TTRRYYBBLLOOCCKKEERRRROORR is set to 0 during the

aallwwaayyss-lliisstt, the error condition caused by the ttrryy-lliisstt is

reset, and shell execution continues normally after the end of

aallwwaayyss-lliisstt. Altering the value during the ttrryy-lliisstt is not use-

ful (unless this forms part of an enclosing aallwwaayyss block).

Regardless of TTRRYYBBLLOOCCKKEERRRROORR, after the end of aallwwaayyss-lliisstt the

normal shell status $$?? is the value returned from aallwwaayyss-lliisstt.

This will be non-zero if there was an error, even if

TTRRYYBBLLOOCCKKEERRRROORR was set to zero. The following executes the given code, ignoring any errors it

causes. This is an alternative to the usual convention of pro-

tecting code by executing it in a subshell. {{

## ccooddee wwhhiicchh mmaayy ccaauussee aann eerrrroorr

}} aallwwaayyss {{

## TThhiiss ccooddee iiss eexxeeccuutteedd rreeggaarrddlleessss ooff tthhee eerrrroorr..

(((( TTRRYYBBLLOOCCKKEERRRROORR == 00 )))) }}

# The error condition has been reset.

An eexxiitt command encountered in ttrryy-lliisstt does not cause the exe-

cution of always-list. Instead, the shell exits immediately

after any EEXXIITT trap has been executed. ffuunnccttiioonn word ... [ (()) ] [ term ] {{ list }} word ... (()) [ term ] {{ list }} word ... (()) [ term ] command where term is one or more newline or ;;. Define a function which is referenced by any one of word. Normally, only one word is provided; multiple words are usually only useful for setting traps. The body of the function is the list between the {{ and }}. See the section `Functions'. If the option SSHHGGLLOOBB is set for compatibility with other shells, then whitespace may appear between between the left and right parentheses when there is a single word; otherwise, the parentheses will be treated as forming a globbing pattern in that case. ttiimmee [ pipeline ] The pipeline is executed, and timing statistics are reported on

the standard error in the form specified by the TTIIMMEEFFMMTT parame-

ter. If pipeline is omitted, print statistics about the shell process and its children. [[[[ exp ]]]] Evaluates the conditional expression exp and return a zero exit status if it is true. See the section `Conditional Expressions' for a description of exp. AALLTTEERRNNAATTEE FFOORRMMSS FFOORR CCOOMMPPLLEEXX CCOOMMMMAANNDDSS Many of zsh's complex commands have alternate forms. These particular versions of complex commands should be considered deprecated and may be removed in the future. The versions in the previous section should be preferred instead. The short versions below only work if sublist is of the form `{{ list }}'

or if the SSHHOORRTTLLOOOOPPSS option is set. For the iiff, wwhhiillee and uunnttiill com-

mands, in both these cases the test part of the loop must also be suit-

ably delimited, such as by `[[[[ ...... ]]]]' or `(((( ...... ))))', else the end of the test will not be recognized. For the ffoorr, rreeppeeaatt, ccaassee and sseelleecctt commands no such special form for the arguments is necessary, but the other condition (the special form of sublist or use of the SSHHOORRTTLLOOOOPPSS option) still applies. iiff list {{ list }} [ eelliiff list {{ list }} ] ... [ eellssee {{ list }} ] An alternate form of iiff. The rules mean that

iiff [[[[ -oo iiggnnoorreebbrraacceess ]]]] {{

pprriinntt yyeess }} works, but

iiff ttrruuee {{ ## DDooeess nnoott wwoorrkk!!

pprriinntt yyeess }} does not, since the test is not suitably delimited. iiff list sublist A short form of the alternate `if'. The same limitations on the form of list apply as for the previous form. ffoorr name ... (( word ... )) sublist A short form of ffoorr. ffoorr name ... [ iinn word ... ] term sublist where term is at least one newline or ;;. Another short form of ffoorr. ffoorr (((( [expr1] ;; [expr2] ;; [expr3] )))) sublist A short form of the arithmetic ffoorr command. ffoorreeaacchh name ... (( word ... )) list eenndd Another form of ffoorr. wwhhiillee list {{ list }} An alternative form of wwhhiillee. Note the limitations on the form of list mentioned above. uunnttiill list {{ list }} An alternative form of uunnttiill. Note the limitations on the form of list mentioned above. rreeppeeaatt word sublist This is a short form of rreeppeeaatt. ccaassee word {{ [ [((] pattern [ || pattern ] ... )) list (;;;;|;;&&) ] ... }} An alternative form of ccaassee. sseelleecctt name [ iinn word term ] sublist where term is at least one newline or ;;. A short form of sseelleecctt. RREESSEERRVVEEDD WWOORRDDSS The following words are recognized as reserved words when used as the

first word of a command unless quoted or disabled using ddiissaabbllee -rr:

ddoo ddoonnee eessaacc tthheenn eelliiff eellssee ffii ffoorr ccaassee iiff wwhhiillee ffuunnccttiioonn rreeppeeaatt ttiimmee uunnttiill sseelleecctt ccoopprroocc nnooccoorrrreecctt ffoorreeaacchh eenndd !! [[[[ {{ }} Additionally, `}}' is recognized in any position if the IIGGNNOORREEBBRRAACCEESS option is not set. CCOOMMMMEENNTTSS

In noninteractive shells, or in interactive shells with the IINNTTEERRAACC-

TTIIVVEECCOOMMMMEENNTTSS option set, a word beginning with the third character of

the hhiissttcchhaarrss parameter (`##' by default) causes that word and all the

following characters up to a newline to be ignored. AALLIIAASSIINNGG Every token in the shell input is checked to see if there is an alias defined for it. If so, it is replaced by the text of the alias if it

is in command position (if it could be the first word of a simple com-

mand), or if the alias is global. If the text ends with a space, the next word in the shell input is treated as though it were in command position for purposes of alias expansion. An alias is defined using

the aalliiaass builtin; global aliases may be defined using the -gg option to

that builtin. Alias expansion is done on the shell input before any other expansion except history expansion. Therefore, if an alias is defined for the word ffoooo, alias expansion may be avoided by quoting part of the word, e.g. \\ffoooo. But there is nothing to prevent an alias being defined for \\ffoooo as well. QQUUOOTTIINNGG

A character may be quoted (that is, made to stand for itself) by pre-

ceding it with a `\\'. `\\' followed by a newline is ignored.

A string enclosed between `$$''' and `''' is processed the same way as the

string arguments of the pprriinntt builtin, and the resulting string is con-

sidered to be entirely quoted. A literal `''' character can be included in the string by using the `\\''' escape. All characters enclosed between a pair of single quotes ('''') that is

not preceded by a `$$' are quoted. A single quote cannot appear within

single quotes unless the option RRCCQQUUOOTTEESS is set, in which case a pair of single quotes are turned into a single quote. For example, pprriinntt '''''''' outputs nothing apart from a newline if RRCCQQUUOOTTEESS is not set, but one single quote if it is set. Inside double quotes (""""), parameter and command substitution occur,

and `\\' quotes the characters `\\', ```', `""', and `$$'.

RREEDDIIRREECCTTIIOONN If a command is followed by && and job control is not active, then the default standard input for the command is the empty file //ddeevv//nnuullll. Otherwise, the environment for the execution of a command contains the file descriptors of the invoking shell as modified by input/output specifications. The following may appear anywhere in a simple command or may precede or follow a complex command. Expansion occurs before word or digit is

used except as noted below. If the result of substitution on word pro-

duces more than one filename, redirection occurs for each separate filename in turn. << word Open file word for reading as standard input. <<>> word Open file word for reading and writing as standard input. If the file does not exist then it is created. >> word Open file word for writing as standard output. If the file does

not exist then it is created. If the file exists, and the CCLLOOBB-

BBEERR option is unset, this causes an error; otherwise, it is truncated to zero length. >>|| word >>!! word Same as >>, except that the file is truncated to zero length if it exists, even if CCLLOOBBBBEERR is unset. >>>> word Open file word for writing in append mode as standard output. If the file does not exist, and the CCLLOOBBBBEERR option is unset, this causes an error; otherwise, the file is created. >>>>|| word >>>>!! word Same as >>>>, except that the file is created if it does not exist, even if CCLLOOBBBBEERR is unset.

<<<<[-] word

The shell input is read up to a line that is the same as word,

or to an end-of-file. No parameter expansion, command substitu-

tion or filename generation is performed on word. The resulting

document, called a here-document, becomes the standard input.

If any character of word is quoted with single or double quotes or a `\\', no interpretation is placed upon the characters of the document. Otherwise, parameter and command substitution occurs, `\\' followed by a newline is removed, and `\\' must be used to

quote the characters `\\', `$$', ```' and the first character of

word.

Note that word itself does not undergo shell expansion. Back-

quotes in word do not have their usual effect; instead they behave similarly to double quotes, except that the backquotes themselves are passed through unchanged. (This information is given for completeness and it is not recommended that backquotes

be used.) Quotes in the form $$''...'' have their standard effect

of expanding backslashed references to special characters.

If <<<<- is used, then all leading tabs are stripped from word and

from the document. <<<<<< word Perform shell expansion on word and pass the result to standard

input. This is known as a here-string. Compare the use of word

in here-documents above, where word does not undergo shell

expansion. <<&& number >>&& number The standard input/output is duplicated from file descriptor number (see dup2(2)).

<<&& -

>>&& - Close the standard input/output.

<<&& pp >>&& pp The input/output from/to the coprocess is moved to the standard input/output. >>&& word &&>> word (Except where `>>&& word' matches one of the above syntaxes; `&&>>' can always be used to avoid this ambiguity.) Redirects both standard output and standard error (file descriptor 2) in the manner of `>> word'. Note that this does not have the same

effect as `>> word 22>>&&11' in the presence of multios (see the sec-

tion below). >>&&|| word >>&&!! word &&>>|| word &&>>!! word

Redirects both standard output and standard error (file descrip-

tor 2) in the manner of `>>|| word'. >>>>&& word &&>>>> word

Redirects both standard output and standard error (file descrip-

tor 2) in the manner of `>>>> word'. >>>>&&|| word >>>>&&!! word &&>>>>|| word &&>>>>!! word

Redirects both standard output and standard error (file descrip-

tor 2) in the manner of `>>>>|| word'. If one of the above is preceded by a digit, then the file descriptor referred to is that specified by the digit instead of the default 0 or 1. The order in which redirections are specified is significant. The shell evaluates each redirection in terms of the (file descriptor, file) association at the time of evaluation. For example: ... 11>>fname 22>>&&11 first associates file descriptor 1 with file fname. It then associates file descriptor 2 with the file associated with file descriptor 1 (that

is, fname). If the order of redirections were reversed, file descrip-

tor 2 would be associated with the terminal (assuming file descriptor 1 had been) and then file descriptor 1 would be associated with file fname. The `||&&' command separator described in Simple Commands & Pipelines in

zshmisc(1) is a shorthand for `22>>&&11 ||'.

For output redirections only, if word is of the form `>>((list))' then the

output is piped to the command represented by list. See Process Sub-

stitution in zshexpn(1). MMUULLTTIIOOSS If the user tries to open a file descriptor for writing more than once, the shell opens the file descriptor as a pipe to a process that copies its input to all the specified outputs, similar to tteeee, provided the MMUULLTTIIOOSS option is set, as it is by default. Thus: ddaattee >>ffoooo >>bbaarr writes the date to two files, named `ffoooo' and `bbaarr'. Note that a pipe is an implicit redirection; thus ddaattee >>ffoooo || ccaatt writes the date to the file `ffoooo', and also pipes it to cat. If the MMUULLTTIIOOSS option is set, the word after a redirection operator is also subjected to filename generation (globbing). Thus :: >> ** will truncate all files in the current directory, assuming there's at least one. (Without the MMUULLTTIIOOSS option, it would create an empty file called `**'.) Similarly, you can do eecchhoo eexxiitt 00 >>>> **..sshh If the user tries to open a file descriptor for reading more than once, the shell opens the file descriptor as a pipe to a process that copies all the specified inputs to its output in the order specified, similar to ccaatt, provided the MMUULLTTIIOOSS option is set. Thus ssoorrtt <> bbaarr >> bbaazz when MMUULLTTIIOOSS is unset will truncate bar, and write `ffoooo' into baz. There is a problem when an output multio is attached to an external program. A simple example shows this: ccaatt ffiillee >>ffiillee11 >>ffiillee22 ccaatt ffiillee11 ffiillee22 Here, it is possible that the second `ccaatt' will not display the full contents of ffiillee11 and ffiillee22 (i.e. the original contents of ffiillee repeated twice). The reason for this is that the multios are spawned after the ccaatt process is forked from the parent shell, so the parent shell does not wait for the multios to finish writing data. This means the command as shown can exit before ffiillee11 and ffiillee22 are completely written. As a workaround, it is possible to run the ccaatt process as part of a job in the current shell: {{ ccaatt ffiillee }} >>ffiillee >>ffiillee22 Here, the {{...}} job will pause to wait for both files to be written. RREEDDIIRREECCTTIIOONNSS WWIITTHH NNOO CCOOMMMMAANNDD When a simple command consists of one or more redirection operators and zero or more parameter assignments, but no command name, zsh can behave in several ways. If the parameter NNUULLLLCCMMDD is not set or the option CCSSHHNNUULLLLCCMMDD is set, an error is caused. This is the ccsshh behavior and CCSSHHNNUULLLLCCMMDD is set by default when emulating ccsshh.

If the option SSHHNNUULLLLCCMMDD is set, the builtin `::' is inserted as a com-

mand with the given redirections. This is the default when emulating sshh or kksshh. Otherwise, if the parameter NNUULLLLCCMMDD is set, its value will be used as a command with the given redirections. If both NNUULLLLCCMMDD and RREEAADDNNUULLLLCCMMDD are set, then the value of the latter will be used instead of that of the former when the redirection is an input. The default for NNUULLLLCCMMDD is `ccaatt' and for RREEAADDNNUULLLLCCMMDD is `mmoorree'. Thus << ffiillee shows the contents of ffiillee on standard output, with paging if that is a terminal. NNUULLLLCCMMDD and RREEAADDNNUULLLLCCMMDD may refer to shell functions. CCOOMMMMAANNDD EEXXEECCUUTTIIOONN If a command name contains no slashes, the shell attempts to locate it. If there exists a shell function by that name, the function is invoked as described in the section `Functions'. If there exists a shell builtin by that name, the builtin is invoked.

Otherwise, the shell searches each element of $$ppaatthh for a directory

containing an executable file by that name. If the search is unsuc-

cessful, the shell prints an error message and returns a nonzero exit status. If execution fails because the file is not in executable format, and the file is not a directory, it is assumed to be a shell script. //bbiinn//sshh is spawned to execute it. If the program is a file beginning

with `##!!', the remainder of the first line specifies an interpreter for

the program. The shell will execute the specified interpreter on oper-

ating systems that do not handle this executable format in the kernel. FFUUNNCCTTIIOONNSS

Shell functions are defined with the ffuunnccttiioonn reserved word or the spe-

cial syntax `funcname (())'. Shell functions are read in and stored

internally. Alias names are resolved when the function is read. Func-

tions are executed like commands with the arguments passed as posi-

tional parameters. (See the section `Command Execution'.) Functions execute in the same process as the caller and share all files and present working directory with the caller. A trap on EEXXIITT set

inside a function is executed after the function completes in the envi-

ronment of the caller. The rreettuurrnn builtin is used to return from function calls.

Function identifiers can be listed with the ffuunnccttiioonnss builtin. Func-

tions can be undefined with the uunnffuunnccttiioonn builtin. AAUUTTOOLLOOAADDIINNGG FFUUNNCCTTIIOONNSS A function can be marked as undefined using the aauuttoollooaadd builtin (or

`ffuunnccttiioonnss -uu' or `ttyyppeesseett -ffuu'). Such a function has no body. When

the function is first executed, the shell searches for its definition using the elements of the ffppaatthh variable. Thus to define functions for autoloading, a typical sequence is:

ffppaatthh==((~~//mmyyffuunnccss $$ffppaatthh))

aauuttoollooaadd mmyyffuunncc11 mmyyffuunncc22 ...... The usual alias expansion during reading will be suppressed if the

aauuttoollooaadd builtin or its equivalent is given the option -UU. This is rec-

ommended for the use of functions supplied with the zsh distribution. Note that for functions precompiled with the zzccoommppiillee builtin command

the flag -UU must be provided when the ..zzwwcc file is created, as the cor-

responding information is compiled into the latter. For each element in ffppaatthh, the shell looks for three possible files, the newest of which is used to load the definition for the function: element..zzwwcc A file created with the zzccoommppiillee builtin command, which is expected to contain the definitions for all functions in the directory named element. The file is treated in the same manner as a directory containing files for functions and is searched for the definition of the function. If the definition is not found, the search for a definition proceeds with the other two possibilities described below. If element already includes a ..zzwwcc extension (i.e. the extension was explicitly given by the user), element is searched for the definition of the function without comparing its age to that of other files; in fact, there does not need to be any directory named element without the suffix. Thus including an element such as `//uussrr//llooccaall//ffuunnccss..zzwwcc' in ffppaatthh will speed up the search for functions, with the disadvantage that functions included must be explicitly recompiled by hand before the shell notices any changes. element//function..zzwwcc A file created with zzccoommppiillee, which is expected to contain the

definition for function. It may include other function defini-

tions as well, but those are neither loaded nor executed; a file

found in this way is searched only for the definition of func-

tion. element//function

A file of zsh command text, taken to be the definition for func-

tion.

In summary, the order of searching is, first, in the parents of direc-

tories in ffppaatthh for the newer of either a compiled directory or a

directory in ffppaatthh; second, if more than one of these contains a defi-

nition for the function that is sought, the leftmost in the ffppaatthh is chosen; and third, within a directory, the newer of either a compiled function or an ordinary function definition is used. If the KKSSHHAAUUTTOOLLOOAADD option is set, or the file contains only a simple definition of the function, the file's contents will be executed. This will normally define the function in question, but may also perform

initialization, which is executed in the context of the function execu-

tion, and may therefore define local parameters. It is an error if the function is not defined by loading the file. Otherwise, the function body (with no surrounding `funcname(()) {{...}}') is taken to be the complete contents of the file. This form allows the file to be used directly as an executable shell script. If processing

of the file results in the function being re-defined, the function

itself is not re-executed. To force the shell to perform initializa-

tion and then call the function defined, the file should contain ini-

tialization code (which will be executed then discarded) in addition to a complete function definition (which will be retained for subsequent calls to the function), and a call to the shell function, including any arguments, at the end. For example, suppose the autoload file ffuunncc contains ffuunncc(()) {{ pprriinntt TThhiiss iiss ffuunncc;; }} pprriinntt ffuunncc iiss iinniittiiaalliizzeedd then `ffuunncc;; ffuunncc' with KKSSHHAAUUTTOOLLOOAADD set will produce both messages on the first call, but only the message `TThhiiss iiss ffuunncc' on the second and

subsequent calls. Without KKSSHHAAUUTTOOLLOOAADD set, it will produce the ini-

tialization message on the first call, and the other message on the second and subsequent calls. It is also possible to create a function that is not marked as autoloaded, but which loads its own definition by searching ffppaatthh, by

using `aauuttoollooaadd -XX' within a shell function. For example, the follow-

ing are equivalent: mmyyffuunncc(()) {{

aauuttoollooaadd -XX

}} mmyyffuunncc aarrggss...... and

uunnffuunnccttiioonn mmyyffuunncc ## iiff mmyyffuunncc wwaass ddeeffiinneedd

aauuttoollooaadd mmyyffuunncc mmyyffuunncc aarrggss......

In fact, the ffuunnccttiioonnss command outputs `bbuuiillttiinn aauuttoollooaadd -XX' as the

body of an autoloaded function. This is done so that

eevvaall ""$$((ffuunnccttiioonnss))""

produces a reasonable result. A true autoloaded function can be iden-

tified by the presence of the comment `## uunnddeeffiinneedd' in the body,

because all comments are discarded from defined functions.

To load the definition of an autoloaded function mmyyffuunncc without execut-

ing mmyyffuunncc, use: aauuttoollooaadd ++XX mmyyffuunncc SSPPEECCIIAALL FFUUNNCCTTIIOONNSS The following functions, if defined, have special meaning to the shell: cchhppwwdd Executed whenever the current working directory is changed. ppeerriiooddiicc If the parameter PPEERRIIOODD is set, this function is executed every

$$PPEERRIIOODD seconds, just before a prompt.

pprreeccmmdd Executed before each prompt. pprreeeexxeecc Executed just after a command has been read and is about to be executed. If the history mechanism is active (and the line was not discarded from the history buffer), the string that the user typed is passed as the first argument, otherwise it is an empty string. The actual command that will be executed (including expanded aliases) is passed in two different forms: the second

argument is a single-line, size-limited version of the command

(with things like function bodies elided); the third argument contains the full text that is being executed. TTRRAAPPNAL

If defined and non-null, this function will be executed whenever

the shell catches a signal SSIIGGNAL, where NAL is a signal name as specified for the kkiillll builtin. The signal number will be passed as the first parameter to the function. If a function of this form is defined and null, the shell and processes spawned by it will ignore SSIIGGNAL. The return value from the function is handled specially. If it

is zero, the signal is assumed to have been handled, and execu-

tion continues normally. Otherwise, the normal effect of the signal is produced; if this causes execution to terminate, the status returned to the shell is the status returned from the function. Programs terminated by uncaught signals typically return the status 128 plus the signal number. Hence the following causes the handler for SSIIGGIINNTT to print a message, then mimic the usual effect of the signal. TTRRAAPPIINNTT(()) {{ pprriinntt ""CCaauugghhtt SSIIGGIINNTT,, aabboorrttiinngg..""

rreettuurrnn $$(((( 112288 ++ $$11 ))))

}}

The functions TTRRAAPPZZEERRRR, TTRRAAPPDDEEBBUUGG and TTRRAAPPEEXXIITT are never exe-

cuted inside other traps. TTRRAAPPDDEEBBUUGG Executed after each command. TTRRAAPPEEXXIITT Executed when the shell exits, or when the current function exits if defined inside a function. TTRRAAPPZZEERRRR

Executed whenever a command has a non-zero exit status. How-

ever, the function is not executed if the command occurred in a sublist followed by `&&&&' or `||||'; only the final command in a sublist of this type causes the trap to be executed. The functions beginning `TTRRAAPP' may alternatively be defined with the ttrraapp builtin: this may be preferable for some uses, as they are then run in the environment of the calling process, rather than in their own function environment. Apart from the difference in calling procedure and the fact that the function form appears in lists of functions, the forms TTRRAAPPNNAALL(()) {{

## ccooddee

}} and ttrraapp ''

## ccooddee

are equivalent. JJOOBBSS If the MMOONNIITTOORR option is set, an interactive shell associates a job with each pipeline. It keeps a table of current jobs, printed by the jjoobbss command, and assigns them small integer numbers. When a job is started asynchronously with `&&', the shell prints a line to standard error which looks like: [[11]] 11223344 indicating that the job which was started asynchronously was job number

1 and had one (top-level) process, whose process ID was 1234.

If a job is started with `&&||' or `&&!!', then that job is immediately disowned. After startup, it does not have a place in the job table, and is not subject to the job control features described here. If you are running a job and wish to do something else you may hit the

key ^Z (control-Z) which sends a TTSSTTPP signal to the current job: this

key may be redefined by the ssuusspp option of the external ssttttyy command.

The shell will then normally indicate that the job has been `sus-

pended', and print another prompt. You can then manipulate the state of this job, putting it in the background with the bbgg command, or run some other commands and then eventually bring the job back into the

foreground with the foreground command ffgg. A ^Z takes effect immedi-

ately and is like an interrupt in that pending output and unread input are discarded when it is typed. A job being run in the background will suspend if it tries to read from the terminal. Background jobs are normally allowed to produce output, but this can be disabled by giving the command `ssttttyy ttoossttoopp'. If you set this tty option, then background jobs will suspend when they try to produce output like they do when they try to read input. When a command is suspended and continued later with the ffgg or wwaaiitt

builtins, zsh restores tty modes that were in effect when it was sus-

pended. This (intentionally) does not apply if the command is contin-

ued via `kkiillll -CCOONNTT', nor when it is continued with bbgg.

There are several ways to refer to jobs in the shell. A job can be referred to by the process ID of any process of the job or by one of the following:

%%number

The job with the given number.

%%string

Any job whose command line begins with string.

%%??string

Any job whose command line contains string.

%%%% Current job.

%%++ Equivalent to `%%%%'.

%%- Previous job.

The shell learns immediately whenever a process changes state. It nor-

mally informs you whenever a job becomes blocked so that no further progress is possible. If the NNOOTTIIFFYY option is not set, it waits until

just before it prints a prompt before it informs you. All such notifi-

cations are sent directly to the terminal, not to the standard output or standard error.

When the monitor mode is on, each background job that completes trig-

gers any trap set for CCHHLLDD. When you try to leave the shell while jobs are running or suspended, you will be warned that `You have suspended (running) jobs'. You may

use the jjoobbss command to see what they are. If you do this or immedi-

ately try to exit again, the shell will not warn you a second time; the suspended jobs will be terminated, and the running jobs will be sent a SSIIGGHHUUPP signal, if the HHUUPP option is set. To avoid having the shell terminate the running jobs, either use the nnoohhuupp command (see nohup(1)) or the ddiissoowwnn builtin. SSIIGGNNAALLSS

The IINNTT and QQUUIITT signals for an invoked command are ignored if the com-

mand is followed by `&&' and the MMOONNIITTOORR option is not active. Other-

wise, signals have the values inherited by the shell from its parent (but see the TTRRAAPPNAL special functions in the section `Functions'). AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN The shell can perform integer and floating point arithmetic, either

using the builtin lleett, or via a substitution of the form $$((((......)))). For

integers, the shell is usually compiled to use 8-byte precision where

this is available, otherwise precision is 4 bytes. This can be tested,

for example, by giving the command `pprriinntt - $$(((( 1122334455667788990011 ))))'; if the

number appears unchanged, the precision is at least 8 bytes. Floating point arithmetic is always double precision. The lleett builtin command takes arithmetic expressions as arguments; each is evaluated separately. Since many of the arithmetic operators, as well as spaces, require quoting, an alternative form is provided: for

any command which begins with a `((((', all the characters until a match-

ing `))))' are treated as a quoted expression and arithmetic expansion performed as for an argument of lleett. More precisely, `((((...))))' is equivalent to `lleett ""...""'. For example, the following statement (((( vvaall == 22 ++ 11 )))) is equivalent to lleett ""vvaall == 22 ++ 11"" both assigning the value 3 to the shell variable vvaall and returning a zero status. Integers can be in bases other than 10. A leading `00xx' or `00XX' denotes

hexadecimal. Integers may also be of the form `base##n', where base is

a decimal number between two and thirty-six representing the arithmetic

base and n is a number in that base (for example, `1166##ffff' is 255 in

hexadecimal). The base## may also be omitted, in which case base 10 is

used. For backwards compatibility the form `[[base]]n' is also accepted. It is also possible to specify a base to be used for output in the form

`[[##base]]', for example `[[##1166]]'. This is used when outputting arith-

metical substitutions or when assigning to scalar parameters, but an explicitly defined integer or floating point parameter will not be

affected. If an integer variable is implicitly defined by an arith-

metic expression, any base specified in this way will be set as the

variable's output arithmetic base as if the option `-ii base' to the

ttyyppeesseett builtin had been used. The expression has no precedence and if

it occurs more than once in a mathematical expression, the last encoun-

tered is used. For clarity it is recommended that it appear at the beginning of an expression. As an example:

ttyyppeesseett -ii 1166 yy

pprriinntt $$(((( [[##88]] xx == 3322,, yy == 3322 ))))

pprriinntt $$xx $$yy

outputs first `88##4400', the rightmost value in the given output base, and

then `88##4400 1166##2200', because yy has been explicitly declared to have out-

put base 16, while xx (assuming it does not already exist) is implicitly typed by the arithmetic evaluation, where it acquires the output base 8. If the CCBBAASSEESS option is set, hexadecimal numbers in the standard C

format, for example 00xxFFFF instead of the usual `1166##FFFF'. If the option

OOCCTTAALLZZEERROOEESS is also set (it is not by default), octal numbers will be

treated similarly and hence appear as `007777' instead of `88##7777'. This

option has no effect on the output of bases other than hexadecimal and octal, and these formats are always understood on input.

When an output base is specified using the `[[##base]]' syntax, an appro-

priate base prefix will be output if necessary, so that the value out-

put is valid syntax for input. If the ## is doubled, for example

`[[####1166]]', then no base prefix is output.

Floating point constants are recognized by the presence of a decimal point or an exponent. The decimal point may be the first character of the constant, but the exponent character ee or EE may not, as it will be taken for a parameter name. An arithmetic expression uses nearly the same syntax, precedence, and

associativity of expressions in C. The following operators are sup-

ported (listed in decreasing order of precedence):

++ - !! ~~ ++++ --

unary plus/minus, logical NOT, complement, {pre,post}{in,de}cre-

ment <<<< >>>> bitwise shift left, right && bitwise AND ^^ bitwise XOR || bitwise OR **** exponentiation

** // %% multiplication, division, modulus (remainder)

++ - addition, subtraction

<< >> <<== >>== comparison ==== !!== equality and inequality &&&& logical AND |||| ^^^^ logical OR, XOR ?? :: ternary operator

== ++== -== **== //== %%== &&== ^^== ||== <<<<== >>>>== &&&&== ||||== ^^^^== ****==

assignment ,, comma operator

The operators `&&&&', `||||', `&&&&==', and `||||==' are short-circuiting, and

only one of the latter two expressions in a ternary operator is evalu-

ated. Note the precedence of the bitwise AND, OR, and XOR operators. Mathematical functions can be called with the syntax `func((args))', where the function decides if the args is used as a string or a

comma-separated list of arithmetic expressions. The shell currently

defines no mathematical functions by default, but the module zzsshh//mmaatthh-

ffuunncc may be loaded with the zzmmooddllooaadd builtin to provide standard float-

ing point mathematical functions.

An expression of the form `####x' where x is any character sequence such

as `aa', `^^AA', or `\\MM-\\CC-xx' gives the ASCII value of this character and

an expression of the form `##foo' gives the ASCII value of the first

character of the value of the parameter foo. Note that this is differ-

ent from the expression `$$##foo', a standard parameter substitution

which gives the length of the parameter foo. `##\\' is accepted instead

of `####', but its use is deprecated.

Named parameters and subscripted arrays can be referenced by name within an arithmetic expression without using the parameter expansion syntax. For example, ((((vvaall22 == vvaall11 ** 22))))

assigns twice the value of $$vvaall11 to the parameter named vvaall22.

An internal integer representation of a named parameter can be speci-

fied with the iinntteeggeerr builtin. Arithmetic evaluation is performed on the value of each assignment to a named parameter declared integer in this manner. Assigning a floating point number to an integer results in rounding down to the next integer. Likewise, floating point numbers can be declared with the ffllooaatt builtin; there are two types, differing only in their output format, as described for the ttyyppeesseett builtin. The output format can be bypassed by using arithmetic substitution instead of the parameter substitution,

i.e. `$${{float}}' uses the defined format, but `$$((((float))))' uses a

generic floating point format.

Promotion of integer to floating point values is performed where neces-

sary. In addition, if any operator which requires an integer (`~~',

`&&', `||', `^^', `%%', `<<<<', `>>>>' and their equivalents with assignment)

is given a floating point argument, it will be silently rounded down to the next integer. Scalar variables can hold integer or floating point values at different times; there is no memory of the numeric type in this case. If a variable is first assigned in a numeric context without previously being declared, it will be implicitly typed as iinntteeggeerr or ffllooaatt and retain that type either until the type is explicitly changed or until the end of the scope. This can have unforeseen consequences. For example, in the loop ffoorr (((( ff == 00;; ff << 11;; ff ++== 00..11 ))));; ddoo

## uussee $$ff

ddoonnee if ff has not already been declared, the first assignment will cause it to be created as an integer, and consequently the operation `ff ++== 00..11' will always cause the result to be truncated to zero, so that the loop will fail. A simple fix would be to turn the initialization into `ff == 00..00'. It is therefore best to declare numeric variables with explicit types. CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS A conditional expression is used with the [[[[ compound command to test attributes of files and to compare strings. Each expression can be

constructed from one or more of the following unary or binary expres-

sions:

-aa file

true if file exists.

-bb file

true if file exists and is a block special file.

-cc file

true if file exists and is a character special file.

-dd file

true if file exists and is a directory.

-ee file

true if file exists.

-ff file

true if file exists and is a regular file.

-gg file

true if file exists and has its setgid bit set.

-hh file

true if file exists and is a symbolic link.

-kk file

true if file exists and has its sticky bit set.

-nn string

true if length of string is non-zero.

-oo option

true if option named option is on. option may be a single char-

acter, in which case it is a single letter option name. (See the section `Specifying Options'.)

-pp file

true if file exists and is a FIFO special file (named pipe).

-rr file

true if file exists and is readable by current process.

-ss file

true if file exists and has size greater than zero.

-tt fd true if file descriptor number fd is open and associated with a

terminal device. (note: fd is not optional)

-uu file

true if file exists and has its setuid bit set.

-ww file

true if file exists and is writable by current process.

-xx file

true if file exists and is executable by current process. If file exists and is a directory, then the current process has permission to search in the directory.

-zz string

true if length of string is zero.

-LL file

true if file exists and is a symbolic link.

-OO file

true if file exists and is owned by the effective user ID of this process.

-GG file

true if file exists and its group matches the effective group ID of this process.

-SS file

true if file exists and is a socket.

-NN file

true if file exists and its access time is not newer than its modification time.

file1 -nntt file2

true if file1 exists and is newer than file2.

file1 -oott file2

true if file1 exists and is older than file2.

file1 -eeff file2

true if file1 and file2 exist and refer to the same file. string == pattern string ==== pattern true if string matches pattern. The `====' form is the preferred one. The `==' form is for backward compatibility and should be considered obsolete. string !!== pattern true if string does not match pattern. string1 << string2 true if string1 comes before string2 based on ASCII value of their characters. string1 >> string2 true if string1 comes after string2 based on ASCII value of their characters.

exp1 -eeqq exp2

true if exp1 is numerically equal to exp2.

exp1 -nnee exp2

true if exp1 is numerically not equal to exp2.

exp1 -lltt exp2

true if exp1 is numerically less than exp2.

exp1 -ggtt exp2

true if exp1 is numerically greater than exp2.

exp1 -llee exp2

true if exp1 is numerically less than or equal to exp2.

exp1 -ggee exp2

true if exp1 is numerically greater than or equal to exp2. (( exp )) true if exp is true. !! exp true if exp is false. exp1 &&&& exp2 true if exp1 and exp2 are both true. exp1 |||| exp2 true if either exp1 or exp2 is true. Normal shell expansion is performed on the file, string and pattern

arguments, but the result of each expansion is constrained to be a sin-

gle word, similar to the effect of double quotes. However, pattern metacharacters are active for the pattern arguments; the patterns are the same as those used for filename generation, see zshexpn(1), but there is no special behaviour of `//' nor initial dots, and no glob qualifiers are allowed. In each of the above expressions, if file is of the form `//ddeevv//ffdd//n', where n is an integer, then the test applied to the open file whose descriptor number is n, even if the underlying system does not support the //ddeevv//ffdd directory. In the forms which do numeric comparison, the expressions exp undergo

arithmetic expansion as if they were enclosed in $$((((......)))).

For example, the following:

[[[[ (( -ff ffoooo |||| -ff bbaarr )) &&&& $$rreeppoorrtt == yy** ]]]] &&&& pprriinntt FFiillee eexxiissttss..

tests if either file ffoooo or file bbaarr exists, and if so, if the value of the parameter rreeppoorrtt begins with `yy'; if the complete condition is true, the message `FFiillee eexxiissttss..' is printed. PPRROOMMPPTT EEXXPPAANNSSIIOONN Prompt sequences undergo a special form of expansion. This type of

expansion is also available using the -PP option to the pprriinntt builtin.

If the PPRROOMMPPTTSSUUBBSSTT option is set, the prompt string is first subjected to parameter expansion, command substitution and arithmetic expansion. See zshexpn(1). Certain escape sequences may be recognised in the prompt string. If the PPRROOMMPPTTBBAANNGG option is set, a `!!' in the prompt is replaced by

the current history event number. A literal `!!' may then be repre-

sented as `!!!!'. If the PPRROOMMPPTTPPEERRCCEENNTT option is set, certain escape sequences that

start with `%%' are expanded. Some escapes take an optional integer

argument, which should appear between the `%%' and the next character of

the sequence. The following escape sequences are recognized: SSppeecciiaall cchhaarraacctteerrss

%%%% A `%%'.

%%)) A `))'.

LLooggiinn iinnffoorrmmaattiioonn

%%ll The line (tty) the user is logged in on, without `//ddeevv//' prefix.

If the name starts with `//ddeevv//ttttyy', that prefix is stripped.

%%MM The full machine hostname.

%%mm The hostname up to the first `..'. An integer may follow the `%%'

to specify how many components of the hostname are desired. With a negative integer, trailing components of the hostname are shown.

%n $USERNAME

%%yy The line (tty) the user is logged in on, without `//ddeevv//' prefix.

This does not treat `//ddeevv//ttttyy' names specially. SShheellll ssttaattee

%%## A `##' if the shell is running with privileges, a `%%' if not.

Equivalent to `%%((!!..##..%%%%))'. The definition of `privileged', for

these purposes, is that either the effective user ID is zero, or, if POSIX.1e capabilities are supported, that at least one capability is raised in either the Effective or Inheritable capability vectors.

%%?? The return code of the last command executed just before the

prompt.

%% The status of the parser, i.e. the shell constructs (like `iiff'

and `ffoorr') that have been started on the command line. If given an integer number that many strings will be printed; zero or negative or no integer means print as many as there are. This is most useful in prompts PPSS22 for continuation lines and PPSS44 for debugging with the XXTTRRAACCEE option; in the latter case it will

also work non-interactively.

%%dd

%%// Present working directory ($$PPWWDD). If an integer follows the

`%%', it specifies a number of trailing components of $$PPWWDD to

show; zero means the whole path. A negative integer specifies

leading components, i.e. %%-11dd specifies the first component.

%%~~ As %%dd and %%//, but if $$PPWWDD has a named directory as its prefix,

that part is replaced by a `~~' followed by the name of the

directory. If it starts with $$HHOOMMEE, that part is replaced by a

`~~'.

%%hh

%%!! Current history event number.

%%ii The line number currently being executed in the script, sourced

file, or shell function given by %%NN. This is most useful for

debugging as part of $$PPSS44.

%%jj The number of jobs.

%%LL The current value of $$SSHHLLVVLL.

%%NN The name of the script, sourced file, or shell function that zsh

is currently executing, whichever was started most recently. If

there is none, this is equivalent to the parameter $$00. An inte-

ger may follow the `%%' to specify a number of trailing path com-

ponents to show; zero means the full path. A negative integer specifies leading components.

%%cc

%%..

%%CC Trailing component of $$PPWWDD. An integer may follow the `%%' to

get more than one component. Unless `%%CC' is used, tilde con-

traction is performed first. These are deprecated as %%cc and %%CC

are equivalent to %%11~~ and %%11//, respectively, while explicit pos-

itive integers have the same effect as for the latter two sequences. DDaattee aanndd ttiimmee

%%DD The date in yy-mm-dd format.

%%TT Current time of day, in 24-hour format.

%%tt

%%@@ Current time of day, in 12-hour, am/pm format.

%%** Current time of day in 24-hour format, with seconds.

%%ww The date in day-dd format.

%%WW The date in mm//dd//yy format.

%%DD{{string}}

string is formatted using the ssttrrffttiimmee function. See strf-

time(3) for more details. Three additional codes are available:

%%ff prints the day of the month, like %%ee but without any preced-

ing space if the day is a single digit, and %%KK/%%LL correspond to

%%kk/%%ll for the hour of the day (24/12 hour clock) in the same

way. VViissuuaall eeffffeeccttss

%%BB (%%bb)

Start (stop) boldface mode.

%%EE Clear to end of line.

%%UU (%%uu)

Start (stop) underline mode.

%%SS (%%ss)

Start (stop) standout mode.

%%{{...%%}}

Include a string as a literal escape sequence. The string within the braces should not change the cursor position. Brace pairs can nest. CCoonnddiittiioonnaall ssuubbssttrriinnggss

%%vv The value of the first element of the ppssvvaarr array parameter.

Following the `%%' with an integer gives that element of the

array. Negative integers count from the end of the array.

%%((x.true-text.false-text))

Specifies a ternary expression. The character following the x is arbitrary; the same character is used to separate the text for the `true' result from that for the `false' result. This

separator may not appear in the true-text, except as part of a

%-escape sequence. A `))' may appear in the false-text as `%%))'.

true-text and false-text may both contain arbitrarily-nested

escape sequences, including further ternary expressions. The left parenthesis may be preceded or followed by a positive integer n, which defaults to zero. A negative integer will be

multiplied by -1. The test character x may be any of the fol-

lowing: !! True if the shell is running with privileges.

## True if the effective uid of the current process is n.

?? True if the exit status of the last command was n. True if at least n shell constructs were started. CC // True if the current absolute path has at least n elements relative to the root directory, hence // is counted as 0 elements. cc .. ~~ True if the current path, with prefix replacement, has at least n elements relative to the root directory, hence // is counted as 0 elements. DD True if the month is equal to n (January = 0). dd True if the day of the month is equal to n. gg True if the effective gid of the current process is n. jj True if the number of jobs is at least n. LL True if the SSHHLLVVLL parameter is at least n. ll True if at least n characters have already been printed on the current line. SS True if the SSEECCOONNDDSS parameter is at least n. TT True if the time in hours is equal to n. tt True if the time in minutes is equal to n. vv True if the array ppssvvaarr has at least n elements. ww True if the day of the week is equal to n (Sunday = 0).

%%<

%%>>string>>

%%[[xstring]]

Specifies truncation behaviour for the remainder of the prompt string. The third, deprecated, form is equivalent to

`%%xstringx', i.e. x may be `<<' or `>>'. The numeric argument,

which in the third form may appear immediately after the `[[', specifies the maximum permitted length of the various strings

that can be displayed in the prompt. The string will be dis-

played in place of the truncated portion of any string; note this does not undergo prompt expansion. The forms with `<<' truncate at the left of the string, and the

forms with `>>' truncate at the right of the string. For exam-

ple, if the current directory is `//hhoommee//ppiikkee', the prompt

`%%88<<....<<%%//' will expand to `....ee//ppiikkee'. In this string, the ter-

minating character (`<<', `>>' or `]]'), or in fact any character,

may be quoted by a preceding `\\'; note when using pprriinntt -PP, how-

ever, that this must be doubled as the string is also subject to standard pprriinntt processing, in addition to any backslashes removed by a double quoted string: the worst case is therefore

`pprriinntt -PP ""%%<<\\\\\\\\<<<<......""'.

If the string is longer than the specified truncation length, it will appear in full, completely replacing the truncated string. The part of the prompt string to be truncated runs to the end of the string, or to the end of the next enclosing group of the

`%%((' construct, or to the next truncation encountered at the

same grouping level (i.e. truncations inside a `%%((' are sepa-

rate), which ever comes first. In particular, a truncation with

argument zero (e.g. `%%<<<<') marks the end of the range of the

string to be truncated while turning off truncation from there

on. For example, the prompt '%10<...<%~%<<%# ' will print a

truncated representation of the current directory, followed by a

`%%' or `##', followed by a space. Without the `%%<<<<', those two

characters would be included in the string to be truncated. zsh 4.2.3 January 13, 2005 ZSHMISC(1)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™