lib/Tools/version
author wenzelm
Sat, 27 Mar 2021 17:13:15 +0100
changeset 73480 0e880b793db1
parent 67872 39b27d38a54c
child 73481 92db3e31fae3
permissions -rwxr-xr-x
support repository archives (without full .hg directory);

#!/usr/bin/env bash
#
# Author: Stefan Berghofer, TU Muenchen
# Author: Makarius
#
# DESCRIPTION: display Isabelle version


PRG="$(basename "$0")"

function usage()
{
  echo
  echo "Usage: isabelle $PRG [OPTIONS]"
  echo
  echo "  Options are:"
  echo "    -i           short identification (derived from Mercurial id)"
  echo
  echo "  Display Isabelle version information."
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}


## process command line

# options

SHORT_ID=""

while getopts "i" OPT
do
  case "$OPT" in
    i)
      SHORT_ID=true
      ;;
    \?)
      usage
      ;;
  esac
done

shift $(($OPTIND - 1))


# args

[ "$#" -ne 0 ] && usage


## main

if [ -n "$SHORT_ID" ]; then
  if [ -n "$ISABELLE_ID" ]; then
    echo "$ISABELLE_ID"
  elif [ -d "$ISABELLE_HOME/.hg" ]; then
    "${HG:-hg}" -R "$ISABELLE_HOME" log -r "p1()" --template="{node|short}\n" 2>/dev/null || echo undefined
  elif [ -f "$ISABELLE_HOME/.hg_archival.txt" ]; then
    fgrep node: < "$ISABELLE_HOME/.hg_archival.txt" | cut -d " " -f2 | head -c12
  else
    echo undefined
  fi
else
  echo 'repository version'    # filled in automatically!
fi