25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
462 B

  1. #!/usr/bin/env bash
  2. # Usage: rbenv version-file-read <file>
  3. set -e
  4. [ -n "$RBENV_DEBUG" ] && set -x
  5. VERSION_FILE="$1"
  6. if [ -e "$VERSION_FILE" ]; then
  7. # Read the first non-whitespace word from the specified version file.
  8. # Be careful not to load it whole in case there's something crazy in it.
  9. IFS="${IFS}"$'\r'
  10. words=( $(cut -b 1-1024 "$VERSION_FILE") )
  11. version="${words[0]}"
  12. if [ -n "$version" ]; then
  13. echo "$version"
  14. exit
  15. fi
  16. fi
  17. exit 1