Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions doc_src/cmds/contains.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Synopsis

.. synopsis::

contains [OPTIONS] KEY [VALUES ...]
contains [OPTIONS] [--] KEY [VALUES ...]

Description
-----------
Expand All @@ -22,7 +22,9 @@ The following options are available:
**-h** or **--help**
Displays help about using this command.

Note that ``contains`` interprets all arguments starting with a **-** as an option to ``contains``, until an **--** argument is reached.
Options must be passed before *KEY*.
All arguments after *KEY* will be considered a value, regardless if they start with a ``-`` or not, including ``--``.
If *KEY* itself starts with a ``-``, use a ``--`` argument to separate it from the options.

See the examples below.

Expand Down Expand Up @@ -62,3 +64,10 @@ While this will check if function ``hasargs`` is being ran with the **-q** optio

The **--** here stops ``contains`` from treating **-q** to an option to itself.
Instead it treats it as a normal string to check.

::

contains -i foo -q -- foo


This returns 3, since all arguments after the key are considered a value.
2 changes: 2 additions & 0 deletions tests/checks/basic.fish
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ contains -i string a b c d; or echo nothing
#CHECK: nothing
contains -i -- string a b c string d
#CHECK: 4
contains -i a -q -- a b c
#CHECK: 3
contains -i -- -- a b c; or echo nothing
#CHECK: nothing
contains -i -- -- a b c -- v
Expand Down
Loading