mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 21:18:53 +00:00
contains: add documentation regarding the use of --
Closes #1194. [skip ci]
This commit is contained in:
parent
a580d04dbc
commit
a31b44f9b2
1 changed files with 11 additions and 0 deletions
|
@ -13,6 +13,7 @@ The following options are available:
|
||||||
|
|
||||||
- `-i` or `--index` print the word index
|
- `-i` or `--index` print the word index
|
||||||
|
|
||||||
|
Note that, like GNU tools, `contains` interprets all arguments starting with a `-` as options to contains, until it reaches an argument that is `--` (two dashes). See the examples below.
|
||||||
|
|
||||||
\subsection contains-example Example
|
\subsection contains-example Example
|
||||||
|
|
||||||
|
@ -25,3 +26,13 @@ end
|
||||||
\endfish
|
\endfish
|
||||||
|
|
||||||
The above code tests if `~/bin` and `/usr/local/bin` are in the path and adds them if not.
|
The above code tests if `~/bin` and `/usr/local/bin` are in the path and adds them if not.
|
||||||
|
|
||||||
|
\fish
|
||||||
|
function hasargs
|
||||||
|
if contains -- -q $argv
|
||||||
|
echo '$argv contains a -q option'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
\endfish
|
||||||
|
|
||||||
|
The above code checks for `-q` in the argument list, using the `--` argument to demarcate options to `contains` from the key to search for.
|
||||||
|
|
Loading…
Reference in a new issue