mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-11 07:34:32 +00:00
0c03b6ddc7
Add an option -i/--index to the contains builtin to print the index of first coincidence.
24 lines
620 B
Text
24 lines
620 B
Text
\section contains contains - test if a word is present in a list
|
|
|
|
\subsection contains-synopsis Synopsis
|
|
<code>contains [OPTIONS] KEY [VALUES...]</code>
|
|
|
|
\subsection contains-description Description
|
|
|
|
- \c -i or \c --index print the the word index
|
|
- \c -h or \c --help display this message
|
|
|
|
Test if the set VALUES contains the string KEY. Return status is 0 if
|
|
yes, 1 otherwise
|
|
|
|
|
|
\subsection contains-example Example
|
|
<pre>
|
|
for i in ~/bin /usr/local/bin
|
|
if not contains \$i \$PATH
|
|
set PATH \$PATH i
|
|
end
|
|
end
|
|
</pre>
|
|
|
|
The above code tests if ~/bin and /usr/local/bin are in the path and if they are not, they are added.
|