1#!/usr/bin/env bash
2# Usage: rbenv version-file-write <file> <version>
3
4set -e
5[ -n "$RBENV_DEBUG" ] && set -x
6
7RBENV_VERSION_FILE="$1"
8RBENV_VERSION="$2"
9
10if [ -z "$RBENV_VERSION" ] || [ -z "$RBENV_VERSION_FILE" ]; then
11  rbenv-help --usage version-file-write >&2
12  exit 1
13fi
14
15# Make sure the specified version is installed.
16rbenv-prefix "$RBENV_VERSION" >/dev/null
17
18# Write the version out to disk.
19echo "$RBENV_VERSION" > "$RBENV_VERSION_FILE"
20