ZSHALL(1)

ZSHALL(1)

zsh Home Page User Commands Index zshbuiltins


NAME
       zshall - the Z shell meta-man page

SYNOPSIS
DESCRIPTION
       Zsh  is  a  UNIX  command interpreter (shell) usable as an
       interactive login shell and as a shell script command pro-
       cessor.   Of  the standard shells, zsh most closely resem-
       bles ksh but includes many enhancements.  Zsh  has  comand
       line  editing,  builtin  spelling correction, programmable
       command completion, shell functions (with autoloading),  a
       history mechanism, and a host of other features.

       This manual page includes all the separate manual pages in
       the following order:  zshmisc (general information),  zsh-
       expn   (command   and  parameter  expansion),  zshbuiltins
       (built-in functions), zshcompctl (completion  control  via
       the compctl built-in), zshparam (shell parameters), zshzle
       (command line editing) and zshoptions (shell options).

zsh version 3.0           June 26, 1996                         1

ZSHMISC(1)                                             ZSHMISC(1)

NAME
       zshmisc - Everything and then some

SYNOPSIS
       Everything I haven't put somewhere else

SHELL GRAMMAR
       A simple command  is  a  sequence  of  optional  parameter
       assignments   followed   by  blank-separated  words,  with
       optional redirections interspersed.  The first word is the
       command  to  be executed, and the remaining words, if any,
       are arguments to the command.  If a command name is given,
       the  parameter  assignments  modify the environment of the
       command when it is executed.  The value of a  simple  com-
       mand  is its exit status, or 128 plus the signal number if
       terminated by a signal.

       A pipeline is a sequence of one or more commands separated
       by  |  or  |&.   |& is shorthand for 2>>&1 |.  The standard
       output of each command is connected to the standard  input
       of  the  next  command  in the pipeline.  If a pipeline is
       preceded by coproc, it is executed as a coprocess; a  two-
       way  pipe  is established between it and the parent shell.
       The shell can read from or write to the coprocess by means
       of  the >>&p and <<&p redirection operators.  The value of a
       pipeline is the value of the last command.  If a  pipeline
       is preceded by a !, the value of that pipeline is the log-
       ical NOT of the value of the last command.

       A sublist is a sequence of one or more pipelines separated
       by  &&  or  ||.  If two pipelines are separated by &&, the
       second pipeline is executed only if the first is  success-
       ful  (returns  a  zero value).  If two pipelines are sepa-
       rated by ||, the second is executed only if the  first  is
       unsuccessful  (returns  a  nonzero value).  Both operators
       have equal precedence and are left associative.

       A list is a sequence of zero or  more  sublists  separated
       by,  and  optionally terminated by, ;, &, &|, &! or a new-
       line.  Normally the shell waits for each  list  to  finish
       before executing the next one.  If a list is terminated by
       &, &| or &!, the shell executes it in the background,  and
       does not wait for it to finish.

PRECOMMAND MODIFIERS
       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
       nocorrect which is a reserved word.

       -      The command is executed with a - prepended  to  its
              argv[0] string.
       noglob Filename  generation (globbing) is not performed on
              any of the words.

zsh version 3.0           June 26, 1996                         1

ZSHMISC(1)                                             ZSHMISC(1)

       nocorrect
              Spelling correction is  not  done  on  any  of  the
              words.
       exec   The command is executed in the parent shell without
              forking.
       command
              The command word is taken to  be  the  name  of  an
              external  command,  rather than a shell function or
              builtin.

COMPLEX COMMANDS
       A complex command in zsh is one of the following:

       if list then list [ elif list then list ] ... [ else list
              ] fi
              The  if list is executed, and, if it returns a zero
              exit status, the then list is executed.  Otherwise,
              the  elif  list  is  executed  and, if its value is
              zero, the then list is executed.  If each elif list
              returns nonzero, the else list is executed.

       for name [ in word ... term ] do list done
              where  term  is  one ore more newline or ;.  Expand
              the list of words, and set the  parameter  name  to
              each of them in turn, executing list each time.  If
              the in word is omitted, use the positional  parame-
              ters instead of the words.

       while list do list done
              Execute  the  do  list  as  long  as the while list
              returns a zero exit status.

       until list do list done
              Execute the do list as long as until list returns a
              nonzero exit status.

       repeat word do list done
              word  is  expanded  and  treated  as  an arithmetic
              expression, which must  evaluate  to  a  number  n.
              list is then executed n times.

       case word in [ [(] pattern [ | pattern ] ... ) list ;; ]
              ... esac
              Execute  the list associated with the first pattern
              that matches word, if any.  The form  of  the  pat-
              terns is the same as that used for filename genera-
              tion.  See Filename Generation below.

       select name [ in word ... term ] do list done
              where term is one ore more newline or ;.  Print the
              set of words, each preceded by a number.  If the in
              word is omitted,  use  the  positional  parameters.
              The  PROMPT3  prompt  is printed and a line is read
              from standard input.  If this line consists of  the

zsh version 3.0           June 26, 1996                         2

ZSHMISC(1)                                             ZSHMISC(1)
              number of one of the listed words, then the parame-
              ter 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  REPLY.  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  trap
              builtin  are  reset  to  their default values while
              executing list.

       { list }
              Execute list.

       function word ... [ () ] [ term ] { list }
       word ... () [ term ] { list }
       word ... () [ term ] command
              where term is one ore 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 FUNCTIONS below.

       time [ pipeline ]
              The pipeline is executed, and timing statistics are
              reported on the standard error in the  form  speci-
              fied  by  the  TIMEFMT  parameter.   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  Conditional
              Expressions below for a description of exp.

ALTERNATE FORMS FOR COMPLEX COMMANDS
       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  NO_SHORT_LOOPS  option  is
       not set.

       if list { list } [ elif list { list } ] ... [ else { list
              } ]
              An alternate form of if.

zsh version 3.0           June 26, 1996                         3

ZSHMISC(1)                                             ZSHMISC(1)

       if list sublist
              A short form of previous one.

       for name ( word ... ) sublist
              A short form of for.

       for name [ in word ... term ] sublist
              where term is one ore more newline or  ;.   Another
              short form of for.

       foreach name ( word ... ) list end
              Another form of for.

       while list { list }
              An alternative form of while.

       until list { list }
              An alternative form of until.

       repeat word sublist
              This is a short form of repeat.

       case word { [ [(] pattern [ | pattern ] ... ) list ;; ]
              ... }
              An alternative form of case.

       select name [ in word term ] sublist
              where term is one ore more newline or ;.   A  short
              form of select.

RESERVED WORDS
       The  following words are recognized as reserved words when
       used as the first word of a command unless quoted or  dis-
       abled using disable -r:
              do  done  esac  then elif else fi for case if while
              function repeat time until select coproc  nocorrect
              foreach end ! [[ { }
              Additionally } is recognized in any position if the
              IGNORE_BRACES option is not set.

COMMENTS
       In noninteractive shells, or in  interactive  shells  with
       the INTERACTIVE_COMMENTS option set, a word beginning with
       the third character of the  histchars  parameter  (`#'  by
       default) causes that word and all the following characters
       up to a newline to be ignored.

ALIASING
       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 command), or if the

zsh version 3.0           June 26, 1996                         4

ZSHMISC(1)                                             ZSHMISC(1)

       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 alias builtin; global aliases
       may be defined using the -g option to that builtin.

       Alias substitution is done on the shell input  before  any
       other  substitution  except  history substitution.  There-
       fore, if an alias is defined for the word foo, alias  sub-
       stitution may be avoided by quoting part of the word, e.g.
       \foo.  But there is nothing  to  prevent  an  alias  being
       defined for \foo as well.

QUOTING
       A  character  may  be  quoted  (that is, made to stand for
       itself) by preceding it with a \.  \ followed by a newline
       is  ignored.   All  characters  enclosed between a pair of
       single quotes ('')  are  quoted.  A  single  quote  cannot
       appear  within  single quotes.  Inside double quotes (""),
       parameter and command substitution occurs,  and  \  quotes
       the characters \, `, ", and $.

REDIRECTION
       Before  a command is executed, its input and output may be
       redirected.  The following may appear anywhere in a simple
       command  or may precede or follow a complex command.  Sub-
       stitution 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 as standard input.

       <<>>word Open  file word for reading and writing as standard
              input.  If the file does not exist then it is  cre-
              ated.

       >>word  Open  file  word  as  standard output.  If the file
              does not exist then it is  created.   If  the  file
              exists,  and  the  CLOBBER  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 CLOBBER is unset.

       >>>>word Open  file  word  as  standard output.  If the file
              exists then output is appended to it.  If the  file
              does  not  exist,  and the CLOBBER option is unset,
              this causes an error; otherwise, the file  is  cre-
              ated.

zsh version 3.0           June 26, 1996                         5

ZSHMISC(1)                                             ZSHMISC(1)

       >>>>| word
       >>>>! word
              Same  as  >>>>, except that the file is created if it
              does not exist, even if CLOBBER 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
              substitution, command substitution or filename gen-
              eration  is performed on word.  The resulting docu-
              ment, 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.  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.

       <<&digit
              The standard input is duplicated from file descrip-
              tor  digit  (see  dup(2)).   Similarly for standard
              output using >>&digit.

       >>&word Same as >>word 2>>&1.

       >>>>&word
              Same as >>>>word 2>>&1.

       <<&-    Close the standard input.

       >>&-    Close the standard output.

       <<&p    The input from the coprocess is moved to the  stan-
              dard input.

       >>&p    The  output  to the coprocess is moved to the stan-
              dard output.

       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 redi-
       rections  are  specified is significant.  The shell evalu-
       ates each redirection in terms of  the  (file  descriptor,
       file) association at the time of evaluation.  For example:
              ... 1>fname 2>&1

zsh version 3.0           June 26, 1996                         6

ZSHMISC(1)                                             ZSHMISC(1)

       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  descriptor 2 would be
       associated with the terminal (assuming file  descriptor  1
       had  been)  and then file descriptor 1 would be associated
       with file fname.

       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  speci-
       fied  outputs,  similar  to  tee(1),  provided the MULTIOS
       option is set.  Thus:
              date >>foo >>bar

       writes the date to two files, named "foo" and "bar".  Note
       that a pipe is an implicit indirection; thus
              date >>foo | cat

       writes  the  date  to the file "foo", and also pipes it to
       cat.

       If the MULTIOS option is set, the word after a redirection
       operator  is  also subjected to filename generation (glob-
       bing).  Thus
              : >> *

       will truncate all files in the current directory, assuming
       there's  at  least  one.   (Without the MULTIOS option, it
       would create an empty file called "*".)

       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 cat(1), pro-
       vided the MULTIOS option is set.  Thus
              sort <<foo <<fubar

       or even
              sort <<f{oo,ubar}

       is equivalent to "cat foo fubar | sort".   Similarly,  you
       can do
              echo exit 0 >>>> *.sh

       Note that a pipe is in implicit indirection; thus
              cat bar | sort <<foo

zsh version 3.0           June 26, 1996                         7

ZSHMISC(1)                                             ZSHMISC(1)

       is  equivalent  to "cat bar foo | sort" (note the order of
       the inputs).

       If the MULTIOS option is unset, each redirection  replaces
       the  previous  redirection for that file descriptor.  How-
       ever, all files redirected to are actually opened, so
              echo foo >> bar >> baz

       when MULTIOS is unset will truncate bar, and  write  "foo"
       into baz.

       If  a  simple  command consists of one or more redirection
       operators and zero or more parameter assignments,  but  no
       command name, the command cat is assumed.  Thus
              << file

       prints the contents of file.

       If  a  command  is  followed  by  & and job control is not
       active, then the default standard input for the command is
       the  empty file /dev/null.  Otherwise, the environment for
       the execution of a command contains the  file  descriptors
       of the invoking shell as modified by input/output specifi-
       cations.

COMMAND EXECUTION
       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 below in  FUNC-
       TIONS.   If there exists a shell builtin by that name, the
       builtin is invoked.

       Otherwise, the shell searches each element of path  for  a
       directory  containing an executable file by that name.  If
       the search is unsuccessful, the shell prints an error mes-
       sage 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.  /bin/sh is spawned to execute it.  If
       the program is a file beginning with #!, the remainder  of
       the  first  line specifies an interpreter for the program.
       The shell will execute the specified interpreter on  oper-
       ating systems that do not handle this executable format in
       the kernel.

FUNCTIONS
       The function reserved word is used to define  shell  func-
       tions.  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 positional parameters.  (See Execution below).

zsh version 3.0           June 26, 1996                         8

ZSHMISC(1)                                             ZSHMISC(1)

       Functions execute in the same process as  the  caller  and
       share  all  files  and  present working directory with the
       caller.  A trap on EXIT set inside a function is  executed
       after  the  function  completes  in the environment of the
       caller.

       The return builtin is used to return from function  calls.

       Function  identifiers  can  be  listed  with the functions
       builtin.  Functions can be undefined with  the  unfunction
       builtin.

       The  following functions, if defined, have special meaning
       to the shell:

       chpwd  Executed whenever the current working directory  is
              changed.
       precmd Executed before each prompt.
       periodic
              If  the  parameter  PERIOD is set, this function is
              executed  every  PERIOD  seconds,  just  before   a
              prompt.
       TRAPxxx
              If defined and non-null, this function will be exe-
              cuted whenever the shell catches a  signal  SIGxxx,
              where  xxx  is  a  signal name as specified for the
              kill builtin (see below).  The signal  number  will
              be  passed  as the first parameter to the function.
              In addition, TRAPZERR is executed whenever  a  com-
              mand  has a non-zero exit status, TRAPDEBUG is exe-
              cuted after each command, and TRAPEXIT is  executed
              when  the shell exits, or when the current function
              exits if defined inside a function.  If a  function
              of  this  form  is  defined and null, the shell and
              processes spawned by it will ignore SIGxxx.

JOBS
       If the MONITOR option is set, an interactive shell associ-
       ates  a  job with each pipeline.  It keeps a table of cur-
       rent jobs, printed by the jobs command, and  assigns  them
       small  integer  numbers.   When  a  job  is  started asyn-
       chronously with &, the shell prints  a  line  which  looks
       like:

            [1] 1234

       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 imme-
       diately disowned.  After startup, it does not have a place
       in  the  job  table, and is not subject to the job control
       features described here.

zsh version 3.0           June 26, 1996                         9

ZSHMISC(1)                                             ZSHMISC(1)

       If you are running a job and wish to do something else you
       may  hit  the key ^Z (control-Z) which sends a TSTP signal
       to the current job.  The shell will then normally indicate
       that  the  job  has  been  `suspended',  and print another
       prompt.  You can then manipulate the state  of  this  job,
       putting  it  in the background with the bg command, or run
       some other commands and then eventually bring the job back
       into  the foreground with the foreground command fg.  A ^Z
       takes effect immediately 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 ``stty tostop''.  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.

       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 normally informs you  whenever  a  job  becomes
       blocked  so  that  no  further  progress  is possible.  If
       notify is not set, it waits until just before it prints  a
       prompt before it informs you.

       When the monitor mode is on, each background job that com-
       pletes triggers any trap set for CHLD.

       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 jobs command to see what
       they  are.   If  you  do  this  or immediately try to exit
       again, the shell will not warn you a second time; the sus-
       pended  jobs will be terminated, and the running jobs will
       be sent a SIGHUP signal.  To avoid having the shell termi-
       nate  the running jobs, either use the nohup(1) command or
       the disown builtin (see below).

SIGNALS
       The INT and  QUIT  signals  for  an  invoked  command  are
       ignored  if  the  command  is  followed  by  & and the job

zsh version 3.0           June 26, 1996                        10

ZSHMISC(1)                                             ZSHMISC(1)

       MONITOR option is not active.  Otherwise, signals have the
       values inherited by the shell from its parent (but see the
       TRAPxxx special function above).

ARITHMETIC EVALUATION
       An ability to perform integer arithmetic is provided  with
       the  builtin  let.   Evaluations  are performed using long
       arithmetic. A leading 0x or 0X denotes hexadecimal.   Oth-
       erwise,  numbers  are 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 exam-
       ple, `16#ff' is 255 in hexadecimal).  If base  is  omitted
       then  base  10  is  used.  For backwards compatibility the
       form `[16]ff' is also accepted.

       An arithmetic expression  uses  nearly  the  same  syntax,
       precedence,  and  associativity  of expressions in C.  The
       following operators are supported  (listed  in  decreasing
       order of precedence):
              + - ! ~ ++ --
                     unary  plus/minus,  logical NOT, complement,
                     {pre,post}{in,de}crement
              <<<< >>>>  bitwise shift left, right
              &      bitwise AND
              ^      bitwise XOR
              |      bitwise OR
              **     exponentiation
              * / %  multiplication, division,  modulus  (remain-
                     der)
              + -    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 evaluated.  Note the precedence of the bitwise
       AND, OR, and XOR operators.

       An expression of the form #\x where  x  is  any  character
       gives  the ascii value of this character and an expression
       of the form #foo gives the ascii value of the first  char-
       acter of the value of the parameter foo.

       Named  parameters and subscripted arrays can be referenced
       by name within an arithmetic expression without using  the
       parameter substitution syntax.

zsh version 3.0           June 26, 1996                        11

ZSHMISC(1)                                             ZSHMISC(1)

       An  internal  integer  representation of a named parameter
       can be specified with  the  integer  builtin.   Arithmetic
       evaluation is performed on the value of each assignment to
       a named parameter declared integer in this manner.

       Since many of the arithmetic operators require quoting, an
       alternative  form of the let command is provided.  For any
       command which begins with a ((, all the characters until a
       matching )) are treated as a quoted expression.  More pre-
       cisely, ((...))  is equivalent to let "...".

CONDITIONAL EXPRESSIONS
       A conditional expression is used with the [[ compound com-
       mand  to  test attributes of files and to compare strings.
       Each expression can be constructed from one or more of the
       following unary or binary expressions:
       -a file
              true if file exists.
       -b file
              true if file exists and is a block special file.
       -c file
              true  if  file  exists  and  is a character special
              file.
       -d file
              true if file exists and is a directory.
       -e file
              true if file exists.
       -f file
              true if file exists and is an ordinary file.
       -g file
              true if file exists and has its setgid bit set.
       -h file
              true if file exists and is a symbolic link.
       -k file
              true if file exists and has its sticky bit set.
       -n string
              true if length of string is non-zero.
       -o option
              true if option named option is on.  option may be a
              single character, in which case it is a single let-
              ter option name.  (See the SPECIFYING OPTIONS  sec-
              tion of the zshoptions(1) man page.)
       -p file
              true if file exists and is a fifo special file or a
              pipe.
       -r file
              true if file exists and is readable by current pro-
              cess.
       -s file
              true if file exists and has size greater than zero.
       -t fd  true if file descriptor number fd is open and asso-
              ciated  with  a  terminal device.  (note: fd is not
              optional)

zsh version 3.0           June 26, 1996                        12

ZSHMISC(1)                                             ZSHMISC(1)

       -u file
              true if file exists and has its setuid bit set.
       -w file
              true if file exists and is writable by current pro-
              cess.
       -x 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.
       -z string
              true if length of string is zero.
       -L file
              true if file exists and is a symbolic link.
       -O file
              true if file exists and is owned by  the  effective
              user id of this process.
       -G file
              true  if  file  exists  and  its  group matches the
              effective group id of this process.
       -S file
              true if file exists and is a socket.
       -N file
              true if file exists and  its  access  time  is  not
              newer than its modification time.
       file1 -nt file2
              true if file1 exists and is newer than file2.
       file1 -ot file2
              true if file1 exists and is older than file2.
       file1 -ef file2
              true if file1 and file2 exist and refer to the same
              file.
       string == pattern
       string = pattern
              true if string matches pattern.  The first form  is
              the  preferred one.  The other 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 -eq exp2
              true if exp1 is equal to exp2.
       exp1 -ne exp2
              true if exp1 is not equal to exp2.
       exp1 -lt exp2
              true if exp1 is less than exp2.
       exp1 -gt exp2
              true if exp1 is greater than exp2.

zsh version 3.0           June 26, 1996                        13

ZSHMISC(1)                                             ZSHMISC(1)

       exp1 -le exp2
              true if exp1 is less than or equal to exp2.
       exp1 -ge exp2
              true if exp1 is 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.

       In each of the above expressions, if file is of  the  form
       /dev/fd/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 /dev/fd directory.

COMPATIBILITY
       Zsh tries to emulate sh or ksh when it is invoked as sh or
       ksh  respectively.   In this mode the following parameters
       are not special and not initialized by  the  shell:  ARGC,
       argv,  cdpath,  fignore,  fpath, HISTCHARS, mailpath, MAN-
       PATH, manpath, path,  prompt,  PROMPT,  PROMPT2,  PROMPT3,
       PROMPT4, psvar, status, watch.

       The  usual  zsh  starup/shutdown scripts are not executed.
       Login shells source /etc/profile followed  by  $HOME/.pro-
       file.   If  the ENV environment variable is set on invoca-
       tion, $ENV is sourced  after  the  profile  scripts.   The
       value  of ENV is subjected to parameter expansion, command
       substitution, and arithmetic expansion before being inter-
       preted  as  a  pathname.   Note that the PRIVILEGED option
       also affects the execution of startup files.   See  zshop-
       tions(1) for more details.

       The  following  options are set if the shell is invoked as
       sh  or  ksh:  NO_BAD_PATTERN,  NO_BANG_HIST,   NO_BG_NICE,
       NO_EQUALS, NO_FUNCTION_ARGZERO, GLOB_SUBST, NO_HUP, INTER-
       ACTIVE_COMMENTS,   KSH_ARRAYS,   NO_MULTIOS,   NO_NOMATCH,
       RM_STAR_SILENT,     POSIX_BUILTINS,     SH_FILE_EXPANSION,
       SH_GLOB, SH_OPTION_LETTERS,  SH_WORD_SPLIT.   Additionally
       the  BSD_ECHO and the IGNORE_BRACES options are set if zsh
       is invoked as sh and the KSH_OPTION_PRINT,  LOCAL_OPTIONS,
       PROMPT_SUBST and SINGLE_LINE_ZLE options are set if zsh is
       invoked as ksh.

zsh version 3.0           June 26, 1996                        14

ZSHEXPN(1)                                             ZSHEXPN(1)

NAME
       zshexpn - zsh command and parameter expansion

DESCRIPTION
       The types of expansions performed are  history  expansion,
       alias  expansion,  process  substitution, parameter expan-
       sion, command substitution,  arithmetic  expansion,  brace
       expansion, filename expansion, and filename generation.

       Exansion  is  done  in  the  above specified order in five
       steps.  The first is History expansion which is only  per-
       formed  in  interactive  shells.   The  next step is alias
       expansion which is done right before the command  line  is
       parsed.  They are followed by process substitution, param-
       eter expansion, command substitution, arithmetic expansion
       and  brace  expansion  which  are preformed in one step in
       left-to-right  fashion.  After   these   expansions,   all
       unquoted  occurrences  of  the  characters \, ', and " are
       removed and the result is subjected to filename  expansion
       followed by filename generation.

       If  the  SH_FILE_EXPANSION  option  is  set,  the order of
       expansion is modified for compatibility with sh  and  ksh.
       Filename  expansion  is  performed immediately after alias
       substitution, preceding the set of five substitutions men-
       tioned above.

FILENAME EXPANSION
       Each  word is checked to see if it begins with an unquoted
       ~.  If it does, then the word up to a /, or the end of the
       word if there is no /, is checked to see if it can be sub-
       stituted in one of the ways described here.  If  so,  then
       the ~ and the checked portion are replaced with the appro-
       priate substitute value.

       A ~ by itself is replaced by the value of the HOME parame-
       ter.   A ~ followed by a + or a - is replaced by the value
       of PWD or OLDPWD, respectively.

       A ~ followed by a number is replaced by the  directory  at
       that position in the directory stack.  ~0 is equivalent to
       ~+, and ~1 is the top of the stack.  ~+ followed by a num-
       ber  is  replaced by the directory at that position in the
       directory stack.  ~+0 is equivalent to ~+, and ~+1 is  the
       top  of the stack.  ~- followed by a number is replaced by
       the directory that many positions from the bottom  of  the
       stack.   ~-0  is the bottom of the stack.  The PUSHD_MINUS
       option exchanges the effects of ~+ and ~- where  they  are
       followed by a number.

       A  ~ followed by anything not already covered is looked up
       as a named directory, and replaced by the  value  of  that
       named directory if found.  Named directories are typically
       home directories for users on the system.  They  may  also

zsh version 3.0           June 26, 1996                         1

ZSHEXPN(1)                                             ZSHEXPN(1)

       be defined if the text after the ~ is the name of a string
       shell parameter whose value begins with a /.  It  is  also
       possible  to  define directory names using the `-d' option
       to the hash builtin.

       In certain circumstances (in prompts, for instance),  when
       the  shell prints a path, the path is checked to see if it
       has a named directory as its prefix.  If so, then the pre-
       fix  portion  is replaced with a ~ followed by the name of
       the directory.  The  shortest  way  of  referring  to  the
       directory  is  used, with ties broken in favour of using a
       named directory, except when the directory is /.

       If a word begins with an unquoted = and the EQUALS  option
       is  set, the remainder of the word is taken as the name of
       a command or alias.  If a command exists by that name, the
       word  is replaced by the full pathname of the command.  If
       an alias exists by that name, the word  is  replaced  with
       the text of the alias.

       Filename  expansion is performed on the right hand side of
       a parameter assignment, including  those  appearing  after
       commands  of  the typeset family.  In this case, the right
       hand side will be treated as a colon-separated list in the
       manner of PATH so that a ~ or an = following a : is eligi-
       ble for expansion.  All such behavior can be  disabled  by
       quoting  the  ~,  the  =, or the whole expression (but not
       simply the colon); the EQUALS option is also respected.

       If the option MAGIC_EQUAL_SUBST is set, any unquoted shell
       argument  in the form identifier=expression becomes eligi-
       ble for file expansion as described in the previous  para-
       graph.  Quoting the first = also inhibits this.

PROCESS SUBSTITUTION
       Each  command  argument  of the form <<(list) or >>(list) or
       =(list) is subject to process substitution.  In  the  case
       of the << or >> forms, the shell will run process list asyn-
       chronously connected to a named pipe (FIFO).  The name  of
       this pipe will become the argument to the command.  If the
       form with >> is selected then writing  on  this  file  will
       provide  input  for  list.   If  <<  is used, then the file
       passed as an argument will be a named  pipe  connected  to
       the output of the list process.  For example,
              paste  <<(cut  -f1  file1)  <<(cut  -f3  file2) | tee
              >>(process1) >>(process2) >/dev/null

       cuts fields 1 and 3 from the files file1 and file2 respec-
       tively,  pastes  the results together, and sends it to the
       processes process1 and  process2.   Note  that  the  file,
       which is passed as an argument to the command, is a system
       pipe so programs that expect to lseek(2) on the file  will
       not work.  Also note that the previous example can be more

zsh version 3.0           June 26, 1996                         2

ZSHEXPN(1)                                             ZSHEXPN(1)

       compactly and efficiently written as:
              paste <<(cut -f1 file1) <<(cut -f3  file2)  >>  >>(pro-
              cess1) >> >>(process2)

       The  shell  uses  pipes  instead of FIFOs to implement the
       latter two process substitutions in the above example.

       If = is used, then the file passed as an argument will  be
       the  name of a temporary file containing the output of the
       list process.  This may be used instead of the << form  for
       a program that expects to lseek(2) on the input file.

PARAMETER EXPANSION
       The character $ is used to introduce parameter expansions.
       See PARAMETERS below for a description of parameters.   In
       the expansions discussed below that require a pattern, the
       form of the pattern is the same as that used for  filename
       generation; see Filename Generation.
              ${name}
                     The  value, if any, of the parameter name is
                     substituted.  The  braces  are  required  if
                     name  is  followed  by  a  letter, digit, or
                     underscore that is not to be interpreted  as
                     part  of  its  name.   If  name  is an array
                     parameter, then the values of  each  element
                     of  name  is  substituted,  one  element per
                     word.  Otherwise, the expansion  results  in
                     one  word only; no word splitting is done on
                     the result.
              ${+name}
                     If name is the name of a set  parameter  `1'
                     is  substituted,  otherwise  `0'  is substi-
                     tuted.
              ${name:-word}
                     If name is set and is non-null then  substi-
                     tute  its  value; otherwise substitute word.
                     If name is missing, substitute word.
              ${name:=word}
                     If name is unset or is null then set  it  to
                     word;  the  value  of  the parameter is then
                     substituted.
              ${name::=word}
                     Set name to word; the value of the parameter
                     is then substituted.
              ${name:?word}
                     If name is set and is non-null, then substi-
                     tute its value; otherwise,  print  word  and

zsh version 3.0           June 26, 1996                         3

ZSHEXPN(1)                                             ZSHEXPN(1)
                     exit  from  the  shell.  If word is omitted,
                     then a standard message is printed.
              ${name:+word}
                     If name is set and is non-null then  substi-
                     tute word; otherwise substitute nothing.
              ${name#pattern}
              ${name##pattern}
                     If  the pattern matches the beginning of the
                     value of name, then substitute the value  of
                     name  with the matched portion deleted; oth-
                     erwise, just substitute the value  of  name.
                     In  the  first  form,  the smallest matching
                     pattern is preferred; in  the  second  form,
                     the  largest  matching pattern is preferred.
                     If name is an array and the substitution  is
                     not quoted or the @ flag or the name[@] syn-
                     tax is used, matching is performed  on  each
                     array elements separately.
              ${name%pattern}
              ${name%%pattern}
                     If  the pattern matches the end of the value
                     of name, then substitute the value  of  name
                     with the matched portion deleted; otherwise,
                     just substitute the value of name.   In  the
                     first form, the smallest matching pattern is
                     preferred; in the second form,  the  largest
                     matching pattern is preferred. If name is an
                     array and the substitution is not quoted  or
                     the  @  flag  or the name[@] syntax is used,
                     matching is performed on each array elements
                     separately.
              ${name:#pattern}
                     If  the  pattern  matches the value of name,
                     then substitute the empty string; otherwise,
                     just  substitute the value of name.  If name
                     is an array  and  the  substitution  is  not
                     quoted  or  the @ flag or the name[@] syntax
                     is used, matching is performed on each array
                     elements  separately,  and the matched array
                     elements are removed  (use  the  M  flag  to
                     remove the non-matched elements).
              ${#spec}
                     If  spec  is one of the above substitutions,
                     substitute the length in characters  of  the
                     result  instead  of  the  result itself.  If
                     spec is an array expression, substitute  the
                     number of elements of the result.
              ${^spec}
                     Turn  on  the RC_EXPAND_PARAM option for the
                     evaluation of spec; if  the  ^  is  doubled,

zsh version 3.0           June 26, 1996                         4

ZSHEXPN(1)                                             ZSHEXPN(1)
                     turn it off.  When this option is set, array
                     expansions of the  form  foo${xx}bar,  where
                     the parameter xx is set to (a b c), are sub-
                     stituted  with   fooabar   foobbar   foocbar
                     instead of the default fooa b cbar.
              ${=spec}
                     Turn  on  the  SH_WORD_SPLIT  option for the
                     evaluation of spec; if  the  =  is  doubled,
                     turn  it  off.   When  this  option  is set,
                     parameter values  are  split  into  separate
                     words  using  IFS as a delimiter before sub-
                     stitution.  This is done by default in  most
                     other shells.
              ${~spec}
                     Turn on the GLOB_SUBST option for the evalu-
                     ation of spec; if the ~ is doubled, turn  it
                     off.   When  this option is set, any pattern
                     characters resulting from  the  substitution
                     become eligible for file expansion and file-
                     name generation.

       If the colon is omitted from one of the above  expressions
       containing  a  colon,  then  the shell only checks whether
       name is set or not, not whether it is null.

       If a ${...} type parameter expression  or  a  $(...)  type
       command substitution is used in place of name above, it is
       substituted first and the result is used as  it  were  the
       value of name.

       If  the  opening  brace is directly followed by an opening
       parentheses the string up to the matching  closing  paren-
       theses  will be taken as a list of flags.  Where arguments
       are valid, any character, or the matching  pairs  `(...)',
       `{...}', `[...]', or `<...>',  may be used in place of the
       colon as delimiters.  The following flags are supported:
              A      Create an array parameter  with  ${...:=...}
                     or  ${...::=...}.  Assignment is made before
                     sorting or padding.
              @      In double quotes,  array  elements  are  put
                     into  separate  words.   Eg.  "${(@)foo}" is
                     equivalent      to      "${foo[@]}"      and
                     "${(@)foo[1,2]}"  is  the  same as "$foo[1]"
                     "$foo[2]".
              e      Perform parameter expansion, command substi-
                     tution   and  arithmetic  expansion  on  the
                     result. Such expansions can  be  nested  but
                     too  deep  recursion  may have unpredictable
                     effects.

zsh version 3.0           June 26, 1996                         5

ZSHEXPN(1)                                             ZSHEXPN(1)
              o      Sort the resulting words in ascending order.
              O      Sort   the  resulting  words  in  descending
                     order.
              i      With o or O, sort case-independently.
              L      Convert all letters in the result  to  lower
                     case.
              U      Convert  all  letters in the result to upper
                     case.
              C      Capitalize the resulting words.
              c      With ${#name}, count  the  total  number  of
                     characters  in  an array, as if the elements
                     were concatenated with spaces between  them.
              w      With  ${#name},  count  words  in  arrays or
                     strings; the s flag may be  used  to  set  a
                     word delimiter.
              W      Similar  to w with the difference that empty
                     words between repeated delimiters  are  also
                     counted.
              p      Recognize  the  same escape sequences as the
                     print builtin in string arguments to  subse-
                     quent flags.
              l:expr::string1::string2:
                     Pad  the  resulting words on the left.  Each
                     word  will  be  truncated  if  required  and
                     placed in a field expr characters wide.  The
                     space  to  the  left  will  be  filled  with
                     string1 (concatenated as often as needed) or
                     spaces if string1 is  not  given.   If  both
                     string1  and  string2 are given, this string
                     will be placed exactly once directly to  the
                     left of the resulting word.
              r:expr::string1::string2:
                     As l..., but pad the words on the right.
              j:string:
                     Join  the  words  of  arrays  together using
                     string  as  a  separator.   Note  that  this
                     occurs   before   word   splitting   by  the
                     SH_WORD_SPLIT option.
              F      Join the words of arrays together using new-
                     line  as  a  separator.  This is a shorthand
                     for pj:\n:.

zsh version 3.0           June 26, 1996                         6

ZSHEXPN(1)                                             ZSHEXPN(1)
              s:string:
                     Force  word  splitting   (see   the   option
                     SH_WORD_SPLIT)   at  the  separator  string.
                     Splitting only occurs  in  places  where  an
                     array value is valid.
              f      Split  the result of the expansion to lines.
                     This is a shorthand for ps:\n:.
              S      (This and all remaining flags are used  with
                     the  ${...#...} or ${...%...} forms): search
                     substrings as well as beginnings or ends.
              I:expr:
                     Search the expr'th match (where expr  evalu-
                     ates to a number).
              M      Include the matched portion in the result.
              R      Include  the unmatched portion in the result
                     (the Rest).
              B      Include the index of the  beginning  of  the
                     match in the result.
              E      Include the index of the end of the match in
                     the result.
              N      Include the  length  of  the  match  in  the
                     result.

COMMAND SUBSTITUTION
       A  command  enclosed  in  parentheses preceded by a dollar
       sign, like so: $(...) or quoted with grave accents:  `...`
       is  replaced  with  its standard output, with any trailing
       newlines deleted.  If the substitution is not enclosed  in
       double  quotes,  the output is broken into words using the
       IFS  parameter.   The  substitution  $(cat  foo)  may   be
       replaced  by the equivalent but faster $(<<foo).  In either
       case, if the option GLOB_SUBST is set the output is eligi-
       ble for filename generation.

ARITHMETIC EXPANSION
       A  string  of  the  form $[exp] or $((exp)) is substituted
       with the value of the arithmetic expression  exp.  exp  is
       subjected to parameter expansion, command substitution and
       arithmetic expansion before it is evaluated.   See  ARITH-
       METIC EVALUATION below.

BRACE EXPANSION
       A  string  of the form foo{xx,yy,zz}bar is expanded to the
       individual words fooxxbar, fooyybar, and foozzbar.   Left-
       to-right  order  is  preserved.   This  construct  may  be

zsh version 3.0           June 26, 1996                         7

ZSHEXPN(1)                                             ZSHEXPN(1)

       nested.  Commas may be quoted in  order  to  include  them
       literally in a word.

       An  expression  of  the form {n1..n2}, where n1 and n2 are
       integers, is expanded to every number between n1  and  n2,
       inclusive.   If  either number begins with a zero, all the
       resulting numbers will be padded with  leading  zeroes  to
       that  minimum  width.   If  the  numbers are in decreasing
       order the resulting sequence will also  be  in  decreasing
       order.

       If  a brace expression matches none of the above forms, it
       is left unchanged, unless the BRACE_CCL option is set.  In
       that case, it is expanded to a sorted list of the individ-
       ual characters between the braces,  in  the  manner  of  a
       search  set.  `-' is treated specially as in a search set,
       but `^' or `!' as the first character is treated normally.

FILENAME GENERATION (GLOBBING)
       If  a  word  contains  an  unquoted instance of one of the
       characters *, |, <, [, or ?, it is regarded as  a  pattern
       for  filename generation, unless the GLOB option is unset.
       If the EXTENDED_GLOB option is set, the ^,  ~ and #  char-
       acters  also  denote  a  pattern; otherwise (except for an
       initial ~, see Filename  Expansion  above)  they  are  not
       treated specially by the shell.  The word is replaced with
       a list of sorted filenames that match the pattern.  If  no
       matching  pattern  is found, the shell gives an error mes-
       sage, unless the NULL_GLOB option is set,  in  which  case
       the  word  is  deleted;  or  unless  the NOMATCH option is
       unset, in which case the word is left unchanged.  In file-
       name  generation,  the character / must be matched explic-
       itly; also, a . must be matched explicitly at  the  begin-
       ning  of  a  pattern  or  after  a /, unless the GLOB_DOTS
       option is set.  No filename generation pattern matches the
       files  "."  or "..".  In other instances of pattern match-
       ing, the / and . are not treated specially.
              *      matches  any  string,  including  the   null
                     string.
              ?      matches any character.
              [...]  matches  any  of  the  enclosed  characters.
                     Ranges of characters  can  be  specified  by
                     separating  two characters by a -.  A - or ]
                     may be matched by including it as the  first
                     character in the list.
              [^...]
              [!...] like [...], except that it matches any char-
                     acter which is not in the given set.
              <<x-y>>  matches any number in  the  range  x  to  y,
                     inclusive.  If x is omitted, the number must
                     be less than or equal to y.  If y  is  omit-
                     ted,  the  number  must  be  greater than or

zsh version 3.0           June 26, 1996                         8

ZSHEXPN(1)                                             ZSHEXPN(1)
                     equal to x.   A  pattern  of  the  form  <<->>
                     matches any number.
              ^x     matches anything except the pattern x.
              x|y    matches either x or y.
              x#     matches zero or more occurrences of the pat-
                     tern x.
              x##    matches one or more occurrences of the  pat-
                     tern x.

       Parentheses  may  be  used  for grouping.  Note that the |
       character must be within parentheses, so that the  lexical
       analyzer does not think it is a pipe character.  Also note
       that "/" has a higher precedence than "^"; that is:
              ls ^foo/bar

       will search directories in "." except "./foo" for  a  file
       named bar.

       A  pathname  component  of the form (foo/)# matches a path
       consisting of zero or more directories matching  the  pat-
       tern  foo.   As  a  shorthand, **/ is equivalent to (*/)#.
       Thus:
              ls (*/)#bar

       or
              ls **/bar

       does a recursive directory search for files named bar, not
       following  symbolic  links.  For this you can use the form
       ***/.

       If used for filename generation, a pattern may contain  an
       exclusion  specifier.   Such  patterns  are  of  the  form
       pat1~pat2.  This pattern will generate all files  matching
       pat1, but which do not match pat2.  For example, *.c~lex.c
       will match all files ending in .c, except the file  lex.c.
       This  may  appear inside parentheses.  Note that "~" has a
       higher precedence than "|", so that pat1|pat2~pat3 matches
       any  time that pat1 matches, or if pat2 matches while pat3
       does not.  Note also that "/" characters are  not  treated
       specially  in  the  exclusion specifier so that a "*" will
       match multiple path segments if they appear in the pattern
       to the left of the "~".

       Patterns  used  for  filename generation may also end in a
       list of qualifiers enclosed in  parentheses.   The  quali-
       fiers  specify  which  filenames  that otherwise match the

zsh version 3.0           June 26, 1996                         9

ZSHEXPN(1)                                             ZSHEXPN(1)

       given pattern will be inserted in the  argument  list.   A
       qualifier may be any one of the following:
              /      directories
              .      plain files
              @      symbolic links
              =      sockets
              p      named pipes (FIFOs)
              *      executable plain files (0100)
              %      device files (character or block special)
              %b     block special files
              %c     character special files
              r      owner-readable files (0400)
              w      owner-writable files (0200)
              x      owner-executable files (0100)
              A      group-readable files (0040)
              I      group-writable files (0020)
              E      group-executable files (0010)
              R      world-readable files (0004)
              W      world-writable files (0002)
              X      world-executable files (0001)
              s      setuid files (04000)
              S      setgid files (02000)
              t      files with the sticky bit (01000)
              ddev   files on the device dev
              l[-|+]ct
                     files  having a link count less than ct (-),
                     greater than ct (+), or is equal to ct
              U      files owned by the effective user id
              G      files owned by the effective group id
              uid    files owned by user id id if it is a number,
                     if  not, than the character after the u will
                     be  used  as  a  separator  and  the  string
                     between  it  and the next matching separator
                     (`(', `[', `{', and `<' match `)', `]', `}',
                     and  `>'  respectively,  any other character
                     matches itself) will be taken as a user name
                     and  the  user id of this user will be taken
                     (e.g. u:foo: or u[foo] for user foo)
              gid    like uid but with group ids or names
              a[Mwhm][-|+]n
                     files accessed exactly n  days  ago.   Files
                     accessed within the last n days are selected
                     using a negative value for  n  (-n).   Files
                     accessed  more  than n days ago are selected
                     by a positive n value (+n).   Optional  unit
                     specifiers  M,  w,  h, or m (e.g. ah5) cause
                     the check to be performed with months (of 30
                     days),  weeks,  hours, or minutes instead of
                     days,  respectively.   For  instance,   echo
                     *(ah-5) would echo files accessed within the
                     last five hours.
              m[Mwhm][-|+]n
                     like the file access qualifier, except  that
                     it uses the file modification time.

zsh version 3.0           June 26, 1996                        10

ZSHEXPN(1)                                             ZSHEXPN(1)
              c[Mwhm][-|+]n
                     like  the file access qualifier, except that
                     it uses the file inode change time.
              L[+|-]n
                     files less than n bytes  (-),  more  than  n
                     bytes  (+), or exactly n bytes in length. If
                     this flag is directly followed by a k (K), m
                     (M), or p (P) (e.g. Lk+50) the check is per-
                     formed with kilobytes, megabytes, or  blocks
                     (of 512 bytes) instead.
              ^      negates all qualifiers following it
              -      toggles  between  making the qualifiers work
                     on symbolic  links  (the  default)  and  the
                     files they point to
              M      sets  the  MARK_DIRS  option for the current
                     pattern
              T      appends a traling qualifier mark to the file
                     names,  analogous  to the LIST_TYPES option,
                     for the current pattern (overrides M)
              N      sets the NULL_GLOB option  for  the  current
                     pattern
              D      sets  the  GLOB_DOTS  option for the current
                     pattern

       More than one of these lists can be combined, separated by
       commas. The whole list matches if at least one of the sub-
       lists matches (they are `or'ed',  the  qualifiers  in  the
       sublists are `and'ed').

       If  a  : appears in a qualifier list, the remainder of the
       expression in parenthesis is  interpreted  as  a  modifier
       (see  the  subsection  Modifiers  of  the  section HISTORY
       EXPANSION).  Note that each modifier must be introduced by
       a  separate  :.  Note also that the result after modifica-
       tion does not have to be an existing file.   The  name  of
       any  existing  file  can  be followed by a modifier of the
       form (:..) even if no filename generation is performed.

       Thus:
              ls *(-/)

       lists all directories and symbolic  links  that  point  to
       directories, and
              ls *(%W)

       lists  all  world-writable  device  files  in  the current
       directory, and
              ls *(W,X)

       lists all files in the current directory that  are  world-
       writable or world-executable, and

zsh version 3.0           June 26, 1996                        11

ZSHEXPN(1)                                             ZSHEXPN(1)
              echo /tmp/foo*(u0^@:t)

       outputs  the  basename  of  all root-owned files beginning
       with the string "foo" in /tmp, ignoring symlinks, and
              ls *.*~(lex|parse).[ch](^D^l1)

       lists all files having a link count  of  one  whose  names
       contain  a  dot  (but not those starting with a dot, since
       GLOB_DOTS is explicitly switched off)  except  for  lex.c,
       lex.h, parse.c, and parse.h.

HISTORY EXPANSION
       History substitution allows you to use words from previous
       command lines in the command line you  are  typing.   This
       simplifies spelling corrections and the repetition of com-
       plicated commands or arguments.  Command lines  are  saved
       in  the  history  list, the size of which is controlled by
       the  HISTSIZE  variable.   The  most  recent  command   is
       retained  in any case.  A history substitution begins with
       the fist character of the histchars parameter which  is  !
       by  default  and  may  occur anywhere on the command line;
       history substitutions do not nest.  The !  can be  escaped
       with  \ or can be enclosed between a pair of single quotes
       ('') to suppress its special meaning. Double  quotes  will
       not work for this.

       Input lines containing history substitutions are echoed on
       the terminal after being expanded, but  before  any  other
       substitutions take place or the command gets executed.

   Event Designators
       An event designator is a reference to a command-line entry
       in the history list.
              !      Start a history  substitution,  except  when
                     followed by a blank, newline, =, or (.
              !!     Refer  to  the previous command.  By itself,
                     this substitution repeats the previous  com-
                     mand.
              !n     Refer to command-line n.
              !-n    Refer to the current command-line minus n.
              !str   Refer  to  the  most recent command starting
                     with str.
              !?str[?]
                     Refer to the most recent command  containing
                     str.
              !#     Refer  to  the current command line typed in
                     so far.  The line is treated as if  it  were
                     complete up to and including the word before
                     the one with the !# reference.
              !{...} Insulate a history reference  from  adjacent
                     characters (if necessary).

zsh version 3.0           June 26, 1996                        12

ZSHEXPN(1)                                             ZSHEXPN(1)

   Word Designators
       A word designator indicates which word or words of a given
       command line will be included in a history  reference.   A
       `:' separates the event specification from the word desig-
       nator.  It can be omitted if the  word  designator  begins
       with a ^, $, *, - or %.  Word designators include:
              0      The first input word (command).
              n      The n'th argument.
              ^      The first argument, that is, 1.
              $      The last argument.
              %      The  word  matched by (the most recent) ?str
                     search.
              x-y    A range of words; -y abbreviates 0-y.
              *      All the arguments, or a null value if  there
                     is just one word in the event.
              x*     Abbreviates x-$.
              x-     Like x* but omitting word $.
       Note  that  a `%' word designator will only work when used
       as !%, !:%, !?str?:% and only when used after a !? substi-
       tution.   Anything  else will result in an error, although
       the error may not be the most obvious one.

   Modifiers
       After the optional word designator, you can add a sequence
       of  one  or more of the following modifiers, each preceded
       by a :.  These modifiers also work on the result of  file-
       name and parameter expansion.
              h      Remove  a trailing pathname component, leav-
                     ing the head.
              r      Remove a trailing suffix of the form `.xxx',
                     leaving the basename.
              e      Remove all but the suffix.
              t      Remove   all  leading  pathname  components,
                     leaving the tail.
              &      Repeat the previous substitution.
              g      Apply the change to the first occurrence  of
                     a match in each word, by prefixing the above
                     (for example, g&).
              p      Print the new command but do not execute it.
              q      Quote  the  substituted words, escaping fur-
                     ther substitutions.
              x      Like q, but break into words at each  blank.
              l      Convert the words to all lowercase.
              u      Convert the words to all uppercase.
              f      Repeats  the  immediately  (without a colon)
                     following modifier until the resulting  word
                     doesn't  change  any more. This and the fol-
                     lowing F, w and W modifier  only  work  with
                     parameter and filename expansion.
              F:expr:
                     Like  f,  but  repeats  only  n times if the
                     expression  expr   evaluates   to   n.   Any

zsh version 3.0           June 26, 1996                        13

ZSHEXPN(1)                                             ZSHEXPN(1)
                     character can be used instead of the `:', if
                     any of `(', `[', or `{' is used as the open-
                     ing  delimiter the second one has to be ')',
                     `]', or `}' respectively.
              w      Makes  the  immediately  following  modifier
                     work on each word in the string.
              W:sep: Like  w  but  words are considered to be the
                     parts of the string that  are  separated  by
                     sep.  Any  character  can be used instead of
                     the `:',  opening  parentheses  are  handled
                     specially, see above.
              s/l/r[/]
                     Substitute r for l.

       Unless  preceded by a g, the substitution is done only for
       the first string that matches l.

       The  left-hand  side  of  substitutions  are  not  regular
       expressions,  but character strings.  Any character can be
       used as the delimiter in place of /.  A  backslash  quotes
       the  delimiter  character.   The character &, in the right
       hand side, is replaced by the  text  from  the  left-hand-
       side.   The  &  can  be quoted with a backslash.  A null l
       uses the previous string either from a l or from a contex-
       tual  scan  string s from !?s.  You can omit the rightmost
       delimiter if a newline immediately follows r;  the  right-
       most ?  in a context scan can similarly be omitted.

       By  default,  a history reference with no event specifica-
       tion refers to the same line as the last history reference
       on  that command line, unless it is the first history ref-
       erence in a command.  In that case,  a  history  reference
       with  no event specification always refers to the previous
       command.  However, if  the  option  CSH_JUNKIE_HISTORY  is
       set,  then  history  reference with no event specification
       will always refer to the previous command.   For  example,
       !!:1  will  always refer to the first word of the previous
       command and !!$ will always refer to the last word of  the
       previous  command.   And with CSH_JUNKIE_HISTORY set, then
       !:1 and !$ will function in the same manner  as  !!:1  and
       !!$,  respectively.   However,  if  CSH_JUNKIE_HISTORY  is
       unset, then !:1 and !$ will refer to the  first  and  last
       words  respectively, of the last command referenced on the
       current command line.  However, if they are the first his-
       tory reference on the command line, then they refer to the
       previous command.

       The character sequence ^foo^bar repeats the last  command,
       replacing the string "foo" with the string "bar".

       If  the shell encounters the character sequence !"  in the
       input, the history mechanism is temporarily disabled until
       the current list is fully parsed.  The !"  is removed from
       the input,  and  any  subsequent  !   characters  have  no

zsh version 3.0           June 26, 1996                        14

ZSHEXPN(1)                                             ZSHEXPN(1)

       special significance.

       A  less convenient but more comprehensible form of command
       history support is provided by the  fc  builtin  (see  the
       entry in the zshbuiltins manual).

zsh version 3.0           June 26, 1996                        15

ZSHBUILTINS(1)                                     ZSHBUILTINS(1)

NAME
       zshbuiltins - zsh built-in functions

DESCRIPTIONS
       - simple command
              See  the secion PRECOMMAND MODIFIERS in zshmisc(1).

       . file [ arg ... ]
              Read commands from file and  execute  them  in  the
              current  shell  environment.  If file does not con-
              tain a slash, or if PATH_DIRS  is  set,  the  shell
              looks  in the components of path to find the direc-
              tory containing file.  Files in the current  direc-
              tory  are  not read unless "." appears somewhere in
              path.  If any arguments arg are given, they  become
              the   positional  parameters;  the  old  positional
              parameters are restored when the file is done  exe-
              cuting.   The exit status is the exit status of the
              last command executed.

       : [ arg ... ]
              This command only expands parameters.  A zero  exit
              code is returned.

       alias [ -gmrL ] [ name[=value] ] ...
              For each name with a corresponding value, define an
              alias with that value.  A trailing space  in  value
              causes  the  next word to be checked for alias sub-
              stitution.  If the -g flag  is  present,  define  a
              global  alias;  global aliases are expanded even if
              they do not occur in command  position.   For  each
              name  with  no  value,  print the value of name, if
              any.   With  no  arguments,  print  all   currently
              defined aliases.  If the -m flag is given the argu-
              ments are taken as patterns (they should be  quoted
              to  preserve  them  from  being interpreted as glob
              patterns) and the aliases matching  these  patterns
              are  printed.   When printing aliases and the -g or
              -r flags are present, then restrict the printing to
              global or regular aliases, respectively.  If the -L
              flag is present, then print each alias in a  manner
              suitable for putting in a startup script.  The exit
              status is nonzero if a  name  (with  no  value)  is
              given for which no alias has been defined.

       autoload [ name ... ]
              For  each  of  the  names (which are names of func-
              tions), create a function  marked  undefined.   The
              fpath  variable will be searched to find the actual
              function definition when the function is first ref-
              erenced.   The definition is contained in a file of
              the same name as the function.  If the  file  found
              contains  a  standard  definition for the function,
              that is stored  as  the  function;  otherwise,  the

zsh version 3.0           June 26, 1996                         1

ZSHBUILTINS(1)                                     ZSHBUILTINS(1)
              contents of the entire file are stored as the func-
              tion.  The latter format  allows  functions  to  be
              used directly as scripts.

       bg [ job ... ]
       job ... &
              Put  each  specified  job in the background, or the
              current job if none is specified.

       bindkey -mevd
       bindkey -r in-string ...
       bindkey [ -a ] in-string [ command ] ...
       bindkey -s [ -a ] in-string out-string ...
              The -e and -v options put the keymaps in emacs mode
              or vi mode respectively; they cannot be used simul-
              taneously. The -d option resets all bindings to the
              compiled-in  settings.  If not used with options -e
              or -v, the maps will be left in emacs mode,  or  in
              vi mode if the VISUAL or EDITOR variables exist and
              contain the string "vi".  Metafied  characters  are
              bound  to  self-insert  by  default.  The -m option
              loads the compiled-in bindings of these  characters
              for  the  mode determined by the preceding options,
              or the current mode if  used  alone.  Any  previous
              bindings done by the user will be preserved. If the
              -r option is given, remove any binding for each in-
              string.  If  the  -s  option is not specified, bind
              each in-string to a specified command. If  no  com-
              mand  is  specified, print the binding of in-string
              if it is bound, or return a nonzero exit code if it
              is  not  bound. If the -s option is specified, bind
              each in-string to each specified  out-string.  When
              in-string  is typed, out-string will be pushed back
              and treated as input to the line editor. This  pro-
              cess is recursive but, to avoid infinite loops, the
              shell will report an error if more than 20 consecu-
              tive replacements happen. If the -a option is spec-
              ified,  bind  the  in-strings  in  the  alternative
              keymap  instead  of the standard one.  The alterna-
              tive keymap is used in vi command mode.
              It's possible for an in-string to be bound to some-
              thing  and  also be the beginning of a longer bound
              string. In this case the shell will wait a  certain
              time to see if more characters are typed and if not
              it  will  execute  the  binding.  This  timeout  is
              defined by the KEYTIMEOUT parameter; its default is
              0.4 sec. No timeout is done if the prefix string is
              not bound.
              For either in-string or out-string, control charac-
              ters may be specified in the form ^X, and the back-
              slash may be used to introduce one of the following
              escape sequences:

zsh version 3.0           June 26, 1996                         2

ZSHBUILTINS(1)                                     ZSHBUILTINS(1)
                      \a     bell character
                      \n     linefeed (newline)
                      \b     backspace
                      \t     horizontal tab
                      \v     vertical tab
                      \f     form feed
                      \r     carriage return
                      \e, \E escape
                      \NNN   character code in octal
                      \xNN   character code in hexadecimal
                      \M-xxx character or  escape  sequence  with
                             meta  bit set. The `-' after the `M'
                             is optional.
                      \C-X   control character.   The  `-'  after
                             the `C' is optional.
              In all other cases, \ escapes the following charac-
              ter.  Delete is written as `^?'. Note  that  `\M^?'
              and `^\M?' are not the same.
              Multi-character  in-strings cannot contain the null
              character ("^@" or "^ "). If they appear in a bind-
              key  command,  they  will be silently translated to
              "\M-^@". This restriction does not  apply  to  out-
              strings,  single-character in-strings and the first
              character of a multi-char in-string.

       break [ n ]
              Exit from an enclosing for, while,  until,  select,
              or  repeat  loop.   If n is specified, then break n
              levels instead of just one.

       builtin name [ args ] ...
              Executes the builtin name, with the given args.

       bye    Same as exit.

       cd [ arg ]
       cd old new
       cd +-n Change the current directory.  In the  first  form,
              change  the  current  directory  to  arg, or to the
              value of HOME if arg is not specified.  If  arg  is
              -,  change  to  the  value  of OLDPWD, the previous
              directory.  If a directory named arg is  not  found
              in  the  current  directory  and arg does not begin
              with a slash, search each component  of  the  shell
              parameter cdpath.  If the option CDABLEVARS is set,
              and a parameter named arg exists whose value begins
              with a slash, treat its value as the directory.
              The  second  form  of cd substitutes the string new
              for the string old  in  the  name  of  the  current
              directory,  and  tries to change to this new direc-
              tory.

zsh version 3.0           June 26, 1996                         3

ZSHBUILTINS(1)                                     ZSHBUILTINS(1)
              The third form of cd extracts  an  entry  from  the
              directory stack, and changes to that directory.  An
              argument of the form +n identifies a stack entry by
              counting  from  the  left  of the list shown by the
              dirs command, starting with zero.  An  argument  of
              the   form  -n  counts  from  the  right.   If  the
              PUSHD_MINUS option is set, the meanings of + and  -
              in this context are swapped.

       chdir  Same as cd.

       command simple command
              See  the secion PRECOMMAND MODIFIERS in zshmisc(1).

       compctl
              Compctl has  it's  own  man  page.   Check  zshcom-
              pctl(1).

       continue [ num ]
              Resume  the  next  iteration  of the enclosing for,
              while, until, select, or  repeat  loop.   If  n  is
              specified,  break  out of n - 1 loops and resume at
              the nth enclosing loop.

       declare [ arg ... ]
              Same as typeset.

       dirs [ -v ] [ arg ... ]
              With no arguments, print the contents of the direc-
              tory  stack.  If the -v option is given, number the
              directories in the stack when  printing.   Directo-
              ries  are  added  to this stack with the pushd com-
              mand, and removed with the cd or popd commands.  If
              arguments  are specified, load them onto the direc-
              tory stack, replacing anything that was there,  and
              push the current directory onto the stack.

       disable [ -afmr ] arg ...
              Disable  the hash table element named arg temporar-
              ily.  The default is to disable  builtin  commands.
              This allows you to use an external command with the
              same name as a  builtin  command.   The  -a  option
              causes  disable  to  act on aliases.  The -f option
              causes disable to act on shell functions.   The  -r
              options  causes  disable  to act on reserved words.
              Without arguments all disabled hash table  elements
              from  the  corresponding  hash  table  are printed.
              With the -m flag the arguments are  taken  as  pat-
              terns (should be quoted to preserve them from being
              taken as glob patterns) and all hash table elements
              from  the  corresponding  hash table matching these
              patterns are disabled.   Disabled  objects  can  be
              enabled with the enable command.

zsh version 3.0           June 26, 1996                         4

ZSHBUILTINS(1)                                     ZSHBUILTINS(1)

       disown [ job ... ]
       job ... &|
       job ... &!
              Remove  the  specified jobs from the job table; the
              shell will no longer report their status, and  will
              not  complain  if  you  try  to exit an interactive
              sh