lib/Tools/getenv
author paulson
Thu, 05 Jun 1997 13:22:25 +0200
changeset 3403 6cc663f6d62e
parent 3007 e5efa177ee0c
child 9788 df671fa2562a
permissions -rwxr-xr-x
A slight simplification of optstring The new "simpset" keyword in the "recdef" declaration
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3007
e5efa177ee0c removed -norc;
wenzelm
parents: 2734
diff changeset
     1
#!/bin/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$
508d2a233dbc *** empty log message ***
wenzelm
parents: 2296
diff changeset
     4
#
2734
e9bbef1b2fbe improved DESCRIPTION;
wenzelm
parents: 2733
diff changeset
     5
# DESCRIPTION: get values from Isabelle settings environment
2307
508d2a233dbc *** empty log message ***
wenzelm
parents: 2296
diff changeset
     6
2296
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
     7
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
     8
## diagnostics
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
     9
2296
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    10
PRG=$(basename $0)
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    11
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    12
function usage()
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    13
{
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    14
  echo
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    15
  echo "Usage: $PRG [OPTIONS] [VARNAMES ...]"
2296
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    16
  echo
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    17
  echo "  Options are:"
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    18
  echo "    -a           display complete environment"
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    19
  echo "    -b           print values only (doesn't work for -a)"
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    20
  echo
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    21
  echo "  Get value of VARNAMES from the Isabelle settings."
2296
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    22
  echo
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    23
  exit 1
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    24
}
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    25
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    26
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    27
## process command line
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    28
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    29
# options
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    30
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    31
ALL=""
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    32
BASE=""
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    33
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    34
while getopts "ab" OPT
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    35
do
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    36
  case "$OPT" in
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    37
    a)
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    38
      ALL=true
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    39
      ;;
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    40
    b)
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    41
      BASE=true
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    42
      ;;
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    43
    \?)
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    44
      usage
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    45
      ;;
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    46
  esac
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    47
done
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    48
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    49
shift $(($OPTIND - 1))
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    50
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    51
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    52
# args
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    53
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    54
[ -n "$ALL" -a $# -ne 0 ] && usage
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    55
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    56
2296
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    57
## main
3b1086cf2f4d getenv: get value from Isabelle settings.
wenzelm
parents:
diff changeset
    58
2733
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    59
if [ -n "$ALL" ]; then
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    60
  env | sort
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    61
else
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    62
  for VAR in $*
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    63
  do
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    64
    if [ -n "$BASE" ]; then
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    65
      eval "echo \$$VAR"
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    66
    else
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    67
      eval "echo $VAR=\$$VAR"
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    68
    fi
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    69
  done
1d1013313201 added -a, -b options;
wenzelm
parents: 2335
diff changeset
    70
fi