lib/Tools/getenv
author paulson
Fri, 22 Apr 2005 17:32:46 +0200
changeset 15817 f79b673da664
parent 14981 e73f8140af78
child 17226 0687c76021c0
permissions -rwxr-xr-x
removed last occurrences of OS.Process.sleep
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10555
2323ec838401 /usr/bin/env bash;
wenzelm
parents: 10511
diff changeset
     1
#!/usr/bin/env bash
2296
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
     2
#
2307
508d2a233dbc *** empty log message ***
wenzelm
parents: 2296
diff changeset
     3
# $Id$
9788
wenzelm
parents: 3007
diff changeset
     4
# Author: Markus Wenzel, TU Muenchen
2307
508d2a233dbc *** empty log message ***
wenzelm
parents: 2296
diff changeset
     5
#
2734
e9bbef1b2fbe improved DESCRIPTION;
wenzelm
parents: 2733
diff changeset
     6
# DESCRIPTION: get values from Isabelle settings environment
2307
508d2a233dbc *** empty log message ***
wenzelm
parents: 2296
diff changeset
     7
2296
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
     8
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
     9
## diagnostics
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    10
10511
wenzelm
parents: 9788
diff changeset
    11
PRG="$(basename "$0")"
2296
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    12
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    13
function usage()
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    14
{
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    15
  echo
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    16
  echo "Usage: $PRG [OPTIONS] [VARNAMES ...]"
2296
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    17
  echo
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    18
  echo "  Options are:"
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    19
  echo "    -a           display complete environment"
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    20
  echo "    -b           print values only (doesn't work for -a)"
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    21
  echo
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    22
  echo "  Get value of VARNAMES from the Isabelle settings."
2296
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    23
  echo
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    24
  exit 1
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    25
}
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    26
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    27
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    28
## process command line
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    29
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    30
# options
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    31
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    32
ALL=""
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    33
BASE=""
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    34
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    35
while getopts "ab" OPT
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    36
do
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    37
  case "$OPT" in
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    38
    a)
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    39
      ALL=true
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    40
      ;;
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    41
    b)
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    42
      BASE=true
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    43
      ;;
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    44
    \?)
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    45
      usage
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    46
      ;;
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    47
  esac
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    48
done
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    49
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    50
shift $(($OPTIND - 1))
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    51
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    52
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    53
# args
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    54
9788
wenzelm
parents: 3007
diff changeset
    55
[ -n "$ALL" -a "$#" -ne 0 ] && usage
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    56
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    57
2296
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    58
## main
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    59
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    60
if [ -n "$ALL" ]; then
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    61
  env | sort
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    62
else
9788
wenzelm
parents: 3007
diff changeset
    63
  for VAR in "$@"
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    64
  do
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    65
    if [ -n "$BASE" ]; then
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    66
      eval "echo \$$VAR"
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    67
    else
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    68
      eval "echo $VAR=\$$VAR"
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    69
    fi
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    70
  done
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    71
fi