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
rvm-1.1.4 scripts/array
rvm-1.1.3 scripts/array
rvm-1.1.2 scripts/array
rvm-1.1.1 scripts/array
rvm-1.1.0 scripts/array
rvm-1.0.23 scripts/array
rvm-1.0.22 scripts/array
rvm-1.0.21 scripts/array
rvm-1.0.20 scripts/array
rvm-1.0.19 scripts/array
rvm-1.0.18 scripts/array
rvm-1.0.17 scripts/array
rvm-1.0.15 scripts/array
gemrage-1.0.0 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array
gemrage-0.4.1 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array
gemrage-0.4.0 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array
gemrage-0.3.2 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array
gemrage-0.3.1 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array
gemrage-0.3.0 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array
gemrage-0.2.0 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array