GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
CONTAINS(1) fish-shell CONTAINS(1)

contains - test if a word is present in a list

contains [OPTIONS] KEY [VALUES...]


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

Note that, like GNU tools and most of fish's builtins, contains interprets all arguments starting with a - as options to contains, until it reaches an argument that is -- (two dashes). See the examples below.

If $animals is a list of animals, the following will test if it contains a cat:

if contains cat $animals
   echo Your animal list is evil!
end


This code will add some directories to $PATH if they aren't yet included:

for i in ~/bin /usr/local/bin
    if not contains $i $PATH
        set PATH $PATH $i
    end
end


While this will check if hasargs was run with the -q option:

function hasargs
    if contains -- -q $argv
        echo '$argv contains a -q option'
    end
end


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

2021, fish-shell developers
April 9, 2022 3.3

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.