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