diff --git a/doc_src/fish_for_bash_users.rst b/doc_src/fish_for_bash_users.rst index e9f014796..68f743c37 100644 --- a/doc_src/fish_for_bash_users.rst +++ b/doc_src/fish_for_bash_users.rst @@ -83,7 +83,7 @@ See :ref:`Shell variables ` for more. Wildcards (globs) ----------------- -Fish only supports the ``*`` and ``**`` glob (and the deprecated ``?`` glob). If a glob doesn't match it fails the command (like with bash's ``failglob``) unless the command is ``for``, ``set`` or ``count`` or the glob is used with an environment override (``VAR=* command``), in which case it expands to nothing (like with bash's ``nullglob`` option). +Fish only supports the ``*`` and ``**`` glob (and the deprecated ``?`` glob) as syntax. If a glob doesn't match it fails the command (like with bash's ``failglob``) unless the command is ``for``, ``set`` or ``count`` or the glob is used with an environment override (``VAR=* command``), in which case it expands to nothing (like with bash's ``nullglob`` option). Globbing doesn't happen on expanded variables, so:: @@ -94,7 +94,7 @@ will not match any files. There are no options to control globbing so it always behaves like that. -See :ref:`Wildcards ` for more. +See :ref:`Wildcards ` for more. For more involved globbing, the :ref:`path ` builtin has the ``path expand`` and ``path match`` subcommands that feature the familiar globs from bash, plus ``**``. Quoting ------- diff --git a/doc_src/language.rst b/doc_src/language.rst index c868cd533..429eac113 100644 --- a/doc_src/language.rst +++ b/doc_src/language.rst @@ -492,6 +492,20 @@ Unlike bash (by default), fish will not pass on the literal glob character if no apt install "ncurses-*" +For more capable wildcards, see the :ref:`path ` builtin, that features the ``path expand`` and ``path match`` subcommands that have full-featured globs, including ``[a-z]`` character ranges (and sets), ``[[:alnum:]]`` character classes and ``?`` for single-character matches. An example:: + + # I want all photos I took in October to December 2019, but not the ".raw" versions + > path expand 'IMG_20191[012]*' | path match -v '*.raw' + IMG_20191002_154337675_HDR.jpg + IMG_20191002_193313306.png + IMG_20191102_195530400_HDR.gif + IMG_20191104_122747460_HDR.jpg + IMG_20191105_195601152 (1).jpg + IMG_20191201_195601152.jpg + + # Okay, now delete them + > rm (path expand 'IMG_20191[012]*' | path match -v '*.raw') + .. _expand-variable: Variable expansion