Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 42 lines (37 sloc) 0.646 kb
#!/usr/bin/env bash
if [[ -n "${ZSH_VERSION:-}" ]]
then
__array_start=1
else
__array_start=0
fi
# Usage: contains "a_string" "${an_array[@]}"
array_contains()
{
typeset pattern index
typeset -a list
pattern="$1"
shift
list=("$@")
for index in "${!list[@]}"
do
[[ ${list[index]} = $pattern ]] && { echo $index ; return 0 ; }
done
echo -1
return 1
}
array_length()
{
array=$1
eval "length=\${#${array}[*]}"
echo $length
return $length
}
array_push()
{
array=$1
item=$2
# TODO: allow loop over more arguments.
eval "index=\$((\${#${array}[*]} + $__array_start))"
eval "${array}[${index}]=${item}"
}
Jump to Line
Something went wrong with that request. Please try again.