fish-shell/doc_src/contains.txt

28 lines
676 B
Text
Raw Normal View History

\section contains contains - test if a word is present in a list
\subsection contains-synopsis Synopsis
2014-08-01 12:25:41 +00:00
\fish{synopsis}
contains [OPTIONS] KEY [VALUES...]
\endfish
\subsection contains-description Description
`contains` tests whether the set `VALUES` contains the string `KEY`. If so, `contains` exits with status 0; if not, it exits with status 1.
The following options are available:
- `-i` or `--index` print the word index
\subsection contains-example Example
\fish
for i in ~/bin /usr/local/bin
if not contains $i $PATH
set PATH $PATH $i
end
end
\endfish
The above code tests if `~/bin` and `/usr/local/bin` are in the path and adds them if not.