Sha256: c44a5085810703c6d8e05f5fc3fd1f2ccb0fdff3c11d1a0ecc02ae1cd0193f01

Contents?: true

Size: 1.12 KB

Versions: 63

Compression:

Stored size: 1.12 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 [[ -z "$rvm_trace_flag" ]] ; then set +x ; else set -x ; fi

if [[ ! -z "$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
  set +x
}

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
rvm-0.1.7 scripts/hash
rvm-0.1.6 scripts/hash
rvm-0.1.5 scripts/hash
rvm-0.1.3 scripts/hash
rvm-0.1.2 scripts/hash
rvm-0.1.1 scripts/hash
rvm-0.1.0 scripts/hash
rvm-0.0.9999 scripts/hash
rvm-0.0.999 scripts/hash
rvm-0.0.99 scripts/hash
rvm-0.0.98 scripts/hash
rvm-0.0.97 scripts/hash
rvm-0.0.96 scripts/hash
rvm-0.0.95 scripts/hash
rvm-0.0.93 scripts/hash
rvm-0.0.92 scripts/hash
rvm-0.0.91 scripts/hash
rvm-0.0.90 scripts/hash
rvm-0.0.89 scripts/hash
rvm-0.0.88 scripts/hash