.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "CONTAINS" "1" "Nov 13, 2025" "4.2" "fish-shell" .SH NAME contains \- test if a word is present in a list .SH SYNOPSIS .nf \fBcontains\fP [\fIOPTIONS\fP] \fIKEY\fP [\fIVALUES\fP \&...] .fi .sp .SH DESCRIPTION .sp \fBcontains\fP tests whether the set \fIVALUES\fP contains the string \fIKEY\fP\&. If so, \fBcontains\fP exits with code 0; if not, it exits with code 1. .sp The following options are available: .INDENT 0.0 .TP \fB\-i\fP or \fB\-\-index\fP Print the index (number of the element in the set) of the first matching element. .TP \fB\-h\fP or \fB\-\-help\fP Displays help about using this command. .UNINDENT .sp Note that \fBcontains\fP interprets all arguments starting with a \fB\-\fP as an option to \fBcontains\fP, until an \fB\-\-\fP argument is reached. .sp See the examples below. .SH EXAMPLE .sp If \fIanimals\fP is a list of animals, the following will test if \fIanimals\fP contains \(dqcat\(dq: .INDENT 0.0 .INDENT 3.5 .sp .EX if contains cat $animals echo Your animal list is evil! end .EE .UNINDENT .UNINDENT .sp This code will add some directories to \fI\%PATH\fP if they aren\(aqt yet included: .INDENT 0.0 .INDENT 3.5 .sp .EX for i in ~/bin /usr/local/bin if not contains $i $PATH set PATH $PATH $i end end .EE .UNINDENT .UNINDENT .sp While this will check if function \fBhasargs\fP is being ran with the \fB\-q\fP option: .INDENT 0.0 .INDENT 3.5 .sp .EX function hasargs if contains \-\- \-q $argv echo \(aq$argv contains a \-q option\(aq end end .EE .UNINDENT .UNINDENT .sp The \fB\-\-\fP here stops \fBcontains\fP from treating \fB\-q\fP to an option to itself. Instead it treats it as a normal string to check. .SH COPYRIGHT fish-shell developers .\" Generated by docutils manpage writer. .