File: rbenv-version-file-read

package info (click to toggle)
rbenv 1.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 380 kB
  • sloc: sh: 1,597; ansic: 60; ruby: 39; makefile: 25
file content (20 lines) | stat: -rwxr-xr-x 396 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
# Usage: rbenv version-file-read <file>
set -e
[ -n "$RBENV_DEBUG" ] && set -x

VERSION_FILE="$1"

if [ -e "$VERSION_FILE" ]; then
  # Read the first word from the specified version file. Avoid reading it whole.
  IFS="${IFS}"$'\r'
  words=( $(cut -b 1-1024 "$VERSION_FILE") )
  version="${words[0]}"

  if [ -n "$version" ]; then
    echo "$version"
    exit
  fi
fi

exit 1