2006-02-08 10:20:43 +00:00
|
|
|
|
2007-01-16 01:29:18 +00:00
|
|
|
function contains --description "Test if a key is contained in a set of values"
|
2006-10-09 21:51:33 +00:00
|
|
|
while count $argv >/dev/null
|
2006-02-08 10:20:43 +00:00
|
|
|
switch $argv[1]
|
|
|
|
case '-h' '--h' '--he' '--hel' '--help'
|
2006-11-17 16:24:38 +00:00
|
|
|
__fish_print_help contains
|
2006-02-08 10:20:43 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
case '--'
|
|
|
|
# End the loop, the next argument is the key
|
|
|
|
set -e argv[1]
|
|
|
|
break
|
|
|
|
|
|
|
|
case '-*'
|
2006-11-17 16:24:38 +00:00
|
|
|
printf (_ "%s: Unknown option '%s'\n") contains $argv[1]
|
|
|
|
__fish_print_help contains >&2
|
2006-02-08 10:20:43 +00:00
|
|
|
return 1
|
|
|
|
|
|
|
|
case '*'
|
|
|
|
# End the loop, we found the key
|
|
|
|
break
|
|
|
|
|
|
|
|
end
|
|
|
|
set -e argv[1]
|
|
|
|
end
|
|
|
|
|
2006-10-09 21:51:33 +00:00
|
|
|
if not count $argv >/dev/null
|
2006-02-08 10:20:43 +00:00
|
|
|
printf (_ "%s: Key not specified\n") contains
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
2006-12-12 20:37:27 +00:00
|
|
|
set key $argv[1]
|
2006-02-08 10:20:43 +00:00
|
|
|
set -e argv[1]
|
|
|
|
|
|
|
|
#
|
|
|
|
# Loop through values
|
|
|
|
#
|
|
|
|
|
2006-11-29 14:00:04 +00:00
|
|
|
printf "%s\n" $argv|sgrep -Fx -- $key >/dev/null
|
2006-02-08 10:20:43 +00:00
|
|
|
return $status
|
|
|
|
end
|
|
|
|
|
|
|
|
|