Sha256: d40302299ae7db704188fee6fe1de32274eeae4d77d8c903d4f81e0695a924ca

Contents?: true

Size: 1.13 KB

Versions: 23

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env bash

#
# The idea is that we emulate a hash using two methods
#
# The first method is providing functions by sourcing this file
#
# The second method is where this script is called directly,
# we then provide functionality of a file based hash
#

if [[ "$rvm_trace_flag" -eq 2 ]] ; then set -x ; export rvm_trace_flag ; fi

if [[ -n "${ZSH_VERSION:-""}" ]] ; then __array_start=1 ; else __array_start=0 ; fi

hash()
{
  hash_name=$1 ; hash_key=$2 ; hash_value=$3

  eval "_hash_${hash_name}_keys=\${_hash_${hash_name}_keys:-()} ; _hash_${hash_name}_values=\${_hash_${hash_name}_values:-()}"

  if [[ -z "$hash_value" ]] ; then
    eval "length=\${#_hash_${hash_name}_keys[@]}"
    for (( index=$__array_start ; index < $length; index++ )) ; do
      eval "key=\"\${_hash_${hash_name}_keys[$index]}\""
      if [[ "$hash_key" = "$key" ]] ; then
        eval "echo -n \${_hash_${hash_name}_values[$index]}"
        break
      fi
    done
  else
    eval "index=\$((\${#_hash_${hash_name}_keys[*]} + $__array_start))"
    eval "_hash_${hash_name}_keys[$index]=\"$hash_key\""
    eval "_hash_${hash_name}_values[$index]=\"$hash_value\""
  fi
}

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
rvm-1.1.4 scripts/hash
rvm-1.1.3 scripts/hash
rvm-1.1.2 scripts/hash
rvm-1.1.1 scripts/hash
rvm-1.1.0 scripts/hash
rvm-1.0.23 scripts/hash
rvm-1.0.22 scripts/hash
rvm-1.0.21 scripts/hash
rvm-1.0.20 scripts/hash
rvm-1.0.19 scripts/hash
rvm-1.0.18 scripts/hash
rvm-1.0.17 scripts/hash
rvm-1.0.15 scripts/hash
gemrage-1.0.0 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hash
gemrage-0.4.1 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hash
gemrage-0.4.0 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hash
gemrage-0.3.2 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hash
gemrage-0.3.1 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hash
gemrage-0.3.0 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hash
gemrage-0.2.0 vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hash