fish-shell/share/functions/contains.fish
axel 536523ffd7 Minor comment and documentation edits
darcs-hash:20060420150206-ac50b-c5c91053ee37a6c3f763287c42b430cdc99bb45b.gz
2006-04-21 01:02:06 +10:00

43 lines
706 B
Fish

function contains -d (N_ "Test if a key is contained in a set of values")
while set -q argv
switch $argv[1]
case '-h' '--h' '--he' '--hel' '--help'
help contains
return
case '--'
# End the loop, the next argument is the key
set -e argv[1]
break
case '-*'
printf (_ "%s: Unknown option '%s'\n") contains $argv[$i]
help contains
return 1
case '*'
# End the loop, we found the key
break
end
set -e argv[1]
end
if not set -q argv
printf (_ "%s: Key not specified\n") contains
return 1
end
set -- key $argv[1]
set -e argv[1]
#
# Loop through values
#
printf "%s\n" $argv|grep -Fx -- $key >/dev/null
return $status
end