GNU Info

Info Node: (zsh.info)Filename Expansion

(zsh.info)Filename Expansion


Next: Filename Generation Prev: Brace Expansion Up: Expansion
Enter node , (file) or (file)node

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 substituted in one of the ways
described here.  If so, then the `~' and the checked portion are
replaced with the appropriate substitute value.

A `~' by itself is replaced by the value of $HOME.  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 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 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 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 prefix 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 / itself.  The parameters $PWD
and $OLDPWD are never abbreviated in this fashion.

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 the PATH parameter, so that a `~'
or an `=' following a `:' is eligible for expansion.  All such
behaviour 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 eligible for file expansion as
described in the previous paragraph.  Quoting the first `=' also
inhibits this.


automatically generated by info2www version 1.2.2.9