fish-shell/doc_src
Fabian Homborg f6fb347d98 Add "path" builtin
This adds a "path" builtin that can handle paths.

Implemented so far:

- "path filter PATHS", filters paths according to existence and optionally type and permissions
- "path base" and "path dir", run basename and dirname, respectively
- "path extension PATHS", prints the extension, if any
- "path strip-extension", prints the path without the extension
- "path normalize PATHS", normalizes paths - removing "/./" components
- and such.
- "path real", does realpath - i.e. normalizing *and* link resolution.

Some of these - base, dir, {strip-,}extension and normalize operate on the paths only as strings, so they handle nonexistent paths. filter and real ignore any nonexistent paths.

All output is split explicitly, so paths with newlines in them are
handled correctly. Alternatively, all subcommands have a "--null-input"/"-z" and "--null-output"/"-Z" option to handle null-terminated input and create null-terminated output. So

    find . -print0 | path base -z

prints the basename of all files in the current directory,
recursively.

With "-Z" it also prints it null-separated.

(if stdout is going to a command substitution, we probably want to
skip this)

All subcommands also have a "-q"/"--quiet" flag that tells them to skip output. They return true "when something happened". For match/filter that's when a file passed, for "base"/"dir"/"extension"/"strip-extension" that's when something about the path *changed*.

Filtering
---------

`filter` supports all the file*types* `test` has - "dir", "file", "link", "block"..., as well as the permissions - "read", "write", "exec" and things like "suid".

It is missing the tty check and the check for the file being non-empty. The former is best done via `isatty`, the latter I don't think I've ever seen used.

There currently is no way to only get "real" files, i.e. ignore links pointing to files.

Examples
--------

> path real /bin///sh
/usr/bin/bash

> path extension foo.mp4
mp4

> path extension ~/.config
  (nothing, because ".config" isn't an extension.)
2022-05-29 17:48:11 +02:00
..
cmds Add "path" builtin 2022-05-29 17:48:11 +02:00
python_docs_theme Remove searchtools.js 2022-05-19 17:38:41 +02:00
commands.rst Add documentation for prompt_hostname 2021-12-04 10:37:49 +01:00
completions.rst Search $__fish_user_data_dir for vendor additions 2022-05-12 20:29:05 +02:00
conf.py docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
design.rst Docs: Posix -> POSIX 2022-02-14 16:18:16 -08:00
faq.rst Remove stray xsel from docs 2022-04-19 18:52:06 +02:00
fish_for_bash_users.rst Fix typo 2022-05-07 14:47:08 +02:00
fish_indent_lexer.py docs: restore default highlighting keywords and options in HTML 2022-01-16 14:07:19 +01:00
fish_synopsis.py docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
index.rst docs/index: reword default shell section 2022-03-29 13:33:06 +08:00
interactive.rst Document some missing color variables 2022-04-24 21:31:51 +02:00
language.rst Search $__fish_user_data_dir for vendor additions 2022-05-12 20:29:05 +02:00
license.rst Bump copyright year 2022-01-09 23:47:58 +08:00
relnotes.rst docs: call the CHANGELOG "release notes" 2021-02-25 22:46:24 +08:00
tutorial.rst docs: Remove prompt from multiline commands 2022-03-11 19:05:26 +01:00