Initial commit

This commit is contained in:
Sam Stephenson 2011-08-01 15:50:26 -05:00
commit 99035a49a9
8 changed files with 139 additions and 0 deletions

18
bin/rbenv Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
set -e
command="$1"
if [ -z "$command" ]; then
echo "rbenv 0.1.0" >&2
else
command_path="$(command -v "rbenv-$command" || true)"
if [ -z "$command_path" ]; then
echo "rbenv: no such command \`$command'" >&2
exit 1
fi
shift 1
exec "$command_path" $*
fi

14
bin/rbenv-exec Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
set -e
RBENV_COMMAND="$1"
if [ -z "$RBENV_COMMAND" ]; then
echo "usage: rbenv exec COMMAND [arg1 arg2...]" >&2
exit 1
fi
RBENV_COMMAND_PATH="$(rbenv-which "$RBENV_COMMAND")"
shift 1
exec -a "$RBENV_COMMAND" "$RBENV_COMMAND_PATH" $*

10
bin/rbenv-rehash Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
set -e
cd "$HOME/.rbenv/shims"
rm *
for file in ../versions/*/bin/*; do
ln -fs ../bin/rbenv-shim "${file##*/}"
done

15
bin/rbenv-set-default Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
RBENV_VERSION="$1"
if [ -z "$RBENV_VERSION" ]; then
echo "usage: rbenv set-default VERSION" >&2
exit 1
fi
RBENV_VERSION_PATH="${HOME}/.rbenv/versions/${RBENV_VERSION}"
if [ ! -d "$RBENV_VERSION_PATH" ]; then
echo "rbenv: version \`${RBENV_VERSION}' not installed" >&2
exit 1
fi
echo "$RBENV_VERSION" > "${HOME}/.rbenv/default"

5
bin/rbenv-shim Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
set -e
exec rbenv-exec "${0##*/}" $*

48
bin/rbenv-version Executable file
View file

@ -0,0 +1,48 @@
#!/bin/bash
set -e
read_version_file() {
egrep -m 1 '[^[:space:]]' "$1"
}
find_version_file() {
root="$(pwd)"
while [ -n "$root" ]; do
if [ -e "${root}/.rbenv-version" ]; then
echo "${root}/.rbenv-version"
return 0
fi
root="${root%/*}"
done
return 1
}
find_default_version_file() {
default_path="$HOME/.rbenv/default"
if [ -e "$default_path" ]; then
echo "$default_path"
return 0
fi
return 1
}
if [ -z "$RBENV_VERSION" ]; then
RBENV_VERSION_FILE="$(find_version_file || find_default_version_file || true)"
if [ -n "$RBENV_VERSION_FILE" ]; then
RBENV_VERSION="$(read_version_file "$RBENV_VERSION_FILE")"
else
echo "rbenv: no default version specified" >&2
exit 1
fi
fi
RBENV_VERSION_PATH="${HOME}/.rbenv/versions/${RBENV_VERSION}"
if [ -d "$RBENV_VERSION_PATH" ]; then
echo "$RBENV_VERSION"
else
echo "rbenv: version \`$RBENV_VERSION' is not installed" >&2
exit 1
fi

15
bin/rbenv-versions Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
RBENV_VERSION="$(rbenv-version)"
for path in ~/.rbenv/versions/*; do
if [ -d "$path" ]; then
version="${path##*/}"
if [ "$version" == "$RBENV_VERSION" ]; then
echo "* ${version##*/}"
else
echo " ${version##*/}"
fi
fi
done

14
bin/rbenv-which Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
set -e
RBENV_VERSION="$(rbenv-version)"
RBENV_COMMAND="$1"
RBENV_COMMAND_PATH="${HOME}/.rbenv/versions/${RBENV_VERSION}/bin/${RBENV_COMMAND}"
if [ -x "$RBENV_COMMAND_PATH" ]; then
echo "$RBENV_COMMAND_PATH"
else
echo "rbenv: $1: command not found" >&2
exit 127
fi