fish-shell/share/functions/contains.fish
axel 32502bfac8 Don't use GREP_OPTIONS in 'contains' function - this is a modified version of a patch by David Bitseff
darcs-hash:20061126131150-ac50b-640bfaf2c3a4111809d9091631b79e35005e68b5.gz
2006-11-26 23:11:50 +10:00

46 lines
809 B
Fish

function contains -d (N_ "Test if a key is contained in a set of values")
while count $argv >/dev/null
switch $argv[1]
case '-h' '--h' '--he' '--hel' '--help'
__fish_print_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[1]
__fish_print_help contains >&2
return 1
case '*'
# End the loop, we found the key
break
end
set -e argv[1]
end
if not count $argv >/dev/null
printf (_ "%s: Key not specified\n") contains
return 1
end
set -- key $argv[1]
set -e argv[1]
# Don't use any grep options!
set -l GREP_OPTIONS
#
# Loop through values
#
printf "%s\n" $argv|grep -Fx -- $key >/dev/null
return $status
end