lib/Tools/getenv
author wenzelm
Tue Apr 22 11:37:12 1997 +0200 (1997-04-22)
changeset 3007 e5efa177ee0c
parent 2734 e9bbef1b2fbe
child 9788 df671fa2562a
permissions -rwxr-xr-x
removed -norc;
     1 #!/bin/bash
     2 #
     3 # $Id$
     4 #
     5 # DESCRIPTION: get values from Isabelle settings environment
     6 
     7 
     8 ## diagnostics
     9 
    10 PRG=$(basename $0)
    11 
    12 function usage()
    13 {
    14   echo
    15   echo "Usage: $PRG [OPTIONS] [VARNAMES ...]"
    16   echo
    17   echo "  Options are:"
    18   echo "    -a           display complete environment"
    19   echo "    -b           print values only (doesn't work for -a)"
    20   echo
    21   echo "  Get value of VARNAMES from the Isabelle settings."
    22   echo
    23   exit 1
    24 }
    25 
    26 
    27 ## process command line
    28 
    29 # options
    30 
    31 ALL=""
    32 BASE=""
    33 
    34 while getopts "ab" OPT
    35 do
    36   case "$OPT" in
    37     a)
    38       ALL=true
    39       ;;
    40     b)
    41       BASE=true
    42       ;;
    43     \?)
    44       usage
    45       ;;
    46   esac
    47 done
    48 
    49 shift $(($OPTIND - 1))
    50 
    51 
    52 # args
    53 
    54 [ -n "$ALL" -a $# -ne 0 ] && usage
    55 
    56 
    57 ## main
    58 
    59 if [ -n "$ALL" ]; then
    60   env | sort
    61 else
    62   for VAR in $*
    63   do
    64     if [ -n "$BASE" ]; then
    65       eval "echo \$$VAR"
    66     else
    67       eval "echo $VAR=\$$VAR"
    68     fi
    69   done
    70 fi