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