The zsh/files Module
====================
The zsh/files module makes some standard commands available as builtins:
chgrp [ -Rs ] GROUP FILENAME ...
Changes group of files specified. This is equivalent to chown with
a USER-SPEC argument of `:GROUP'.
chown [ -Rs ] USER-SPEC FILENAME ...
Changes ownership and group of files specified.
The USER-SPEC can be in four forms:
USER
change owner to USER; do not change group
USER::
change owner to USER; do not change group
USER:
change owner to USER; change group to USER's primary group
USER:GROUP
change owner to USER; change group to GROUP
:GROUP
do not change owner; change group to GROUP
In each case, the `:' may instead be a `.'. The rule is that if
there is a `:' then the separator is `:', otherwise if there is a
`.' then the separator is `.', otherwise there is no separator.
Each of USER and GROUP may be either a username (or group name, as
appropriate) or a decimal user ID (group ID). Interpretation as a
name takes precedence, if there is an all-numeric username (or
group name).
The -R option causes chown to recursively descend into directories,
changing the ownership of all files in the directory after
changing the ownership of the directory itself.
The -s option is a zsh extension to chown functionality. It
enables paranoid behaviour, intended to avoid security problems
involving a chown being tricked into affecting files other than
the ones intended. It will refuse to follow symbolic links, so
that (for example) ``chown luser /tmp/foo/passwd'' can't
accidentally chown /etc/passwd if /tmp/foo happens to be a link to
/etc. It will also check where it is after leaving directories,
so that a recursive chown of a deep directory tree can't end up
recursively chowning /usr as a result of directories being moved
up the tree.
ln [ -dfis ] FILENAME DEST
ln [ -dfis ] FILENAME ... DIR
Creates hard (or, with -s, symbolic) links. In the first form, the
specified DESTination is created, as a link to the specified
FILENAME. In the second form, each of the FILENAMEs is taken in
turn, and linked to a pathname in the specified DIRectory that has
the same last pathname component.
Normally, ln will not attempt to create hard links to directories.
This check can be overridden using the -d option. Typically only
the super-user can actually succeed in creating hard links to
directories. This does not apply to symbolic links in any case.
By default, existing files cannot be replaced by links. The -i
option causes the user to be queried about replacing existing
files. The -f option causes existing files to be silently
deleted, without querying. -f takes precedence.
mkdir [ -p ] [ -m MODE ] DIR ...
Creates directories. With the -p option, non-existing parent
directories are first created if necessary, and there will be no
complaint if the directory already exists. The -m option can be
used to specify (in octal) a set of file permissions for the
created directories, otherwise mode 777 modified by the current
umask (see man page umask(2)) is used.
mv [ -fi ] FILENAME DEST
mv [ -fi ] FILENAME ... DIR
Moves files. In the first form, the specified FILENAME is moved
to the specified DESTination. In the second form, each of the
FILENAMEs is taken in turn, and moved to a pathname in the
specified DIRectory that has the same last pathname component.
By default, the user will be queried before replacing any file
that the user cannot write to, but writable files will be silently
removed. The -i option causes the user to be queried about
replacing any existing files. The -f option causes any existing
files to be silently deleted, without querying. -f takes
precedence.
Note that this mv will not move files across devices. Historical
versions of mv, when actual renaming is impossible, fall back on
copying and removing files; if this behaviour is desired, use cp
and rm manually. This may change in a future version.
rm [ -dfirs ] FILENAME ...
Removes files and directories specified.
Normally, rm will not remove directories (except with the -r
option). The -d option causes rm to try removing directories with
unlink (see man page unlink(2)), the same method used for files.
Typically only the super-user can actually succeed in unlinking
directories in this way. -d takes precedence over -r.
By default, the user will be queried before removing any file that
the user cannot write to, but writable files will be silently
removed. The -i option causes the user to be queried about
removing any files. The -f option causes files to be silently
deleted, without querying, and suppresses all error indications.
-f takes precedence.
The -r option causes rm to recursively descend into directories,
deleting all files in the directory before removing the directory
with the rmdir system call (see man page rmdir(2)).
The -s option is a zsh extension to rm functionality. It enables
paranoid behaviour, intended to avoid common security problems
involving a root-run rm being tricked into removing files other
than the ones intended. It will refuse to follow symbolic links,
so that (for example) ``rm /tmp/foo/passwd'' can't accidentally
remove /etc/passwd if /tmp/foo happens to be a link to /etc. It
will also check where it is after leaving directories, so that a
recursive removal of a deep directory tree can't end up
recursively removing /usr as a result of directories being moved
up the tree.
rmdir DIR ...
Removes empty directories specified.
sync
Calls the system call of the same name (see man page sync(2)),
which flushes dirty buffers to disk. It might return before the
I/O has actually been completed.