added -a, -b options;
authorwenzelm
Wed Mar 05 17:13:56 1997 +0100 (1997-03-05)
changeset 27331d1013313201
parent 2732 84fc9c3b6bf0
child 2734 e9bbef1b2fbe
added -a, -b options;
multiple VARNAMES;
lib/Tools/getenv
     1.1 --- a/lib/Tools/getenv	Wed Mar 05 14:19:34 1997 +0100
     1.2 +++ b/lib/Tools/getenv	Wed Mar 05 17:13:56 1997 +0100
     1.3 @@ -5,21 +5,66 @@
     1.4  # DESCRIPTION: get value from Isabelle settings
     1.5  
     1.6  
     1.7 +## diagnostics
     1.8 +
     1.9  PRG=$(basename $0)
    1.10  
    1.11  function usage()
    1.12  {
    1.13    echo
    1.14 -  echo "Usage: $PRG VARNAME"
    1.15 +  echo "Usage: $PRG [OPTIONS] [VARNAMES ...]"
    1.16    echo
    1.17 -  echo "  Get value of VARNAME from the Isabelle settings."
    1.18 +  echo "  Options are:"
    1.19 +  echo "    -a           display complete environment"
    1.20 +  echo "    -b           print values only (doesn't work for -a)"
    1.21 +  echo
    1.22 +  echo "  Get value of VARNAMES from the Isabelle settings."
    1.23    echo
    1.24    exit 1
    1.25  }
    1.26  
    1.27  
    1.28 +## process command line
    1.29 +
    1.30 +# options
    1.31 +
    1.32 +ALL=""
    1.33 +BASE=""
    1.34 +
    1.35 +while getopts "ab" OPT
    1.36 +do
    1.37 +  case "$OPT" in
    1.38 +    a)
    1.39 +      ALL=true
    1.40 +      ;;
    1.41 +    b)
    1.42 +      BASE=true
    1.43 +      ;;
    1.44 +    \?)
    1.45 +      usage
    1.46 +      ;;
    1.47 +  esac
    1.48 +done
    1.49 +
    1.50 +shift $(($OPTIND - 1))
    1.51 +
    1.52 +
    1.53 +# args
    1.54 +
    1.55 +[ -n "$ALL" -a $# -ne 0 ] && usage
    1.56 +
    1.57 +
    1.58  ## main
    1.59  
    1.60 -[ $# -ne 1 ] && usage
    1.61 -
    1.62 -eval "echo \$$1"
    1.63 +if [ -n "$ALL" ]; then
    1.64 +  env | sort
    1.65 +else
    1.66 +  for VAR in $*
    1.67 +  do
    1.68 +    if [ -n "$BASE" ]; then
    1.69 +      eval "echo \$$VAR"
    1.70 +    else
    1.71 +      eval "echo $VAR=\$$VAR"
    1.72 +    fi
    1.73 +  done
    1.74 +fi