1#!/usr/bin/env bash
2#
3# Author: Stefan Berghofer, TU Muenchen
4# Author: Makarius
5#
6# DESCRIPTION: display Isabelle version
7
8
9PRG="$(basename "$0")"
10
11function usage()
12{
13  echo
14  echo "Usage: isabelle $PRG [OPTIONS]"
15  echo
16  echo "  Options are:"
17  echo "    -i           short identification (derived from Mercurial id)"
18  echo
19  echo "  Display Isabelle version information."
20  echo
21  exit 1
22}
23
24function fail()
25{
26  echo "$1" >&2
27  exit 2
28}
29
30
31## process command line
32
33# options
34
35SHORT_ID=""
36
37while getopts "i" OPT
38do
39  case "$OPT" in
40    i)
41      SHORT_ID=true
42      ;;
43    \?)
44      usage
45      ;;
46  esac
47done
48
49shift $(($OPTIND - 1))
50
51
52# args
53
54[ "$#" -ne 0 ] && usage
55
56
57## main
58
59if [ -n "$SHORT_ID" ]; then
60  if [ -n "$ISABELLE_ID" ]; then
61    echo "$ISABELLE_ID"
62  else
63    "${HG:-hg}" -R "$ISABELLE_HOME" log -r "p1()" --template="{node|short}\n" 2>/dev/null || echo undefined
64  fi
65else
66  echo 'repository version'    # filled in automatically!
67fi
68