#!/usr/bin/env bash

__rvm_load_rvmrc()
{
  if (( ${rvm_ignore_rvmrc:=0} == 1 ))
  then
    return 0
  fi

  for rvmrc in /etc/rvmrc "$HOME/.rvmrc"
  do
    if [[ -f "$rvmrc" ]]
    then
      if command grep '^\s*rvm .*$' $rvmrc >/dev/null 2>&1 ; then
        rvm_error "
$rvmrc is for rvm settings only.
rvm CLI may NOT be called from within $rvmrc.
Skipping the loading of $rvmrc
"
        return 1
      else
        source "$rvmrc"
      fi
    fi
  done

  return 0
}

# Initialize rvm, ensuring that the path and directories are as expected.
__rvm_initialize()
{
  rvm_ruby_load_path="."
  rvm_ruby_require=""

  true ${rvm_scripts_path:="$rvm_path/scripts"}
  source "$rvm_scripts_path/base"

  __rvm_clean_path
  __rvm_conditionally_add_bin_path
  export PATH

  if [[ ! -d "${rvm_tmp_path:-/tmp}" ]]
  then
    command mkdir -p "${rvm_tmp_path}"
  fi

  return 0
}
