Sha256: e58415a5177983bcee3ba8a9ff7089173c5a1160b748b92fbc99cd013d089ed2
Contents?: true
Size: 634 Bytes
Versions: 23
Compression:
Stored size: 634 Bytes
Contents
#!/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() { local pattern="$1" ; shift local index list 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}" }
Version data entries
23 entries across 23 versions & 2 rubygems
Version | Path |
---|---|
gemrage-0.1.2 | vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array |
rvm-1.0.14 | scripts/array |
rvm-1.0.13 | scripts/array |