Sha256: aaf8c7b7336281df33848a93355b8299998b43a271a0d90c3153f18748077791

Contents?: true

Size: 820 Bytes

Versions: 45

Compression:

Stored size: 820 Bytes

Contents

#!/usr/bin/env bash

if [[ -f "$1" ]] ; then
  database_file="$1" ; shift
  if [[ ! -f "$database_file" ]] ; then
    mkdir -p $(dirname $database_file)
    touch $database_file
  fi
else
  echo "usage: $0 database key [value]"
  exit 1
fi

key="$1" ; shift
if [[ -z "$key" ]] ; then
  echo "usage: $0 database key [value]"
  exit 1
else
  value="$*"
  if [[ "unset" = "$value" ]] || [[ "delete" = "$value" ]] ; then
    sed -i.tmp "s#^$key=.*\$##" $database_file
  else
    if [[ -z "$value" ]] ; then # get
      awk -F= '/^'"$key"'=/{print $2}' $database_file
    else # set
      if [[ -z "$(awk -F= "/^'"$key"'=/{print $2}" $database_file)" ]] ; then # append
        echo "$key=$value" >> $database_file
      else # overwrite
        sed -i.tmp "s#^$key=.*\$#$key=$value#" $database_file
      fi
    fi
  fi
fi

Version data entries

45 entries across 45 versions & 1 rubygems

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