fish-shell/doc_src/cmds/umask.rst

58 lines
2.7 KiB
ReStructuredText
Raw Normal View History

.. _cmd-umask:
umask - set or get the file creation mode mask
==============================================
Synopsis
--------
docs synopsis: add HTML highlighing and automate manpage markup Recent synopsis changes move from literal code blocks to [RST line blocks]. This does not translate well to HTML: it's not rendered in monospace, so aligment is lost. Additionally, we don't get syntax highlighting in HTML, which adds differences to our code samples which are highlighted. We hard-wrap synopsis lines (like code blocks). To align continuation lines in manpages we need [backslashes in weird places]. Combined with the **, *, and `` markup, it's a bit hard to get the alignment right. Fix these by moving synopsis sources back to code blocks and compute HTML syntax highlighting and manpage markup with a custom Sphinx extension. The new Pygments lexer can tokenize a synopsis and assign the various highlighting roles, which closely matches fish's syntax highlighing: - command/keyword (dark blue) - parameter (light blue) - operator like and/or/not/&&/|| (cyan) - grammar metacharacter (black) For manpage output, we don't project the fish syntax highlighting but follow the markup convention in GNU's man(1): bold text type exactly as shown. italic text replace with appropriate argument. To make it easy to separate these two automatically, formalize that (italic) placeholders must be uppercase; while all lowercase text is interpreted literally (so rendered bold). This makes manpages more consistent, see string-join(1) and and(1). Implementation notes: Since we want manpage formatting but Sphinx's Pygments highlighing plugin does not support manpage output, add our custom "synopsis" directive. This directive parses differently when manpage output is specified. This means that the HTML and manpage build processes must not share a cache, because the parsed doctrees are cached. Work around this by using separate cache locations for build targets "sphinx-docs" (which creates HTML) and "sphinx-manpages". A better solution would be to only override Sphinx's ManualPageBuilder but that would take a bit more code (ideally we could override ManualPageWriter but Sphinx 4.3.2 doesn't really support that). --- Alternative solution: stick with line blocks but use roles like :command: or :option: (or custom ones). While this would make it possible to produce HTML that is consistent with code blocks (by adding a bit of CSS), the source would look uglier and is harder to maintain. (Let's say we want to add custom formatting to the [|] metacharacters in HTML. This is much easier with the proposed patch.) --- [RST line blocks]: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#line-blocks [backslashes in weird places]: https://github.com/fish-shell/fish-shell/pull/8626#discussion_r782837750
2022-01-09 22:09:46 +08:00
.. synopsis::
umask [OPTIONS] [MASK]
Description
-----------
.. only:: builder_man
NOTE: This page documents the fish builtin ``umask``.
To see the documentation on any non-fish versions, use ``command man umask``.
``umask`` displays and manipulates the "umask", or file creation mode mask, which is used to restrict the default access to files.
The umask may be expressed either as an octal number, which represents the rights that will be removed by default, or symbolically, which represents the only rights that will be granted by default.
Access rights are explained in the manual page for the ``chmod(1)`` program.
With no parameters, the current file creation mode mask is printed as an octal number.
**-S** or **--symbolic**
Prints the umask in symbolic form instead of octal form.
**-p** or **--as-command**
Outputs the umask in a form that may be reused as input.
**-h** or **--help**
Displays help about using this command.
If a numeric mask is specified as a parameter, the current shell's umask will be set to that value, and the rights specified by that mask will be removed from new files and directories by default.
If a symbolic mask is specified, the desired permission bits, and not the inverse, should be specified. A symbolic mask is a comma separated list of rights. Each right consists of three parts:
- The first part specifies to whom this set of right applies, and can be one of ``u``, ``g``, ``o`` or ``a``, where ``u`` specifies the user who owns the file, ``g`` specifies the group owner of the file, ``o`` specific other users rights and ``a`` specifies all three should be changed.
- The second part of a right specifies the mode, and can be one of ``=``, ``+`` or ``-``, where ``=`` specifies that the rights should be set to the new value, ``+`` specifies that the specified right should be added to those previously specified and ``-`` specifies that the specified rights should be removed from those previously specified.
- The third part of a right specifies what rights should be changed and can be any combination of ``r``, ``w`` and ``x``, representing read, write and execute rights.
If the first and second parts are skipped, they are assumed to be ``a`` and ``=``, respectively. As an example, ``r,u+w`` means all users should have read access and the file owner should also have write access.
Note that symbolic masks currently do not work as intended.
Example
-------
``umask 177`` or ``umask u=rw`` sets the file creation mask to read and write for the owner and no permissions at all for any other users.