diff options
author | axel <axel@liljencrantz.se> | 2006-02-17 20:13:39 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-02-17 20:13:39 +1000 |
commit | 343cafef346543282b5b6e825bc8f9dd10028a48 (patch) | |
tree | 1bcf221ecb525c7aeadc8325e7b780d3656e544b /share/functions/contains.fish | |
parent | 95a01f3c8f15034433ffce368d8f2d13d925139c (diff) |
Redo installation file structure, move lots of things to $PREFIX/share/fish
darcs-hash:20060217101339-ac50b-d93d2c620a4b7f75f05ff461a6edbee001da7613.gz
Diffstat (limited to 'share/functions/contains.fish')
-rw-r--r-- | share/functions/contains.fish | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/share/functions/contains.fish b/share/functions/contains.fish new file mode 100644 index 00000000..331794c7 --- /dev/null +++ b/share/functions/contains.fish @@ -0,0 +1,49 @@ +# +# This file defines various shellscript functions. Most of them are +# meant to be used directly by the user, but some of them, typically +# the ones whose name start with '__fish_', are only meant to be used +# internally by fish. +# + +function contains -d (_ "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 + + |