lib/Tools/getenv
author wenzelm
Sun, 22 Mar 2020 22:03:48 +0100
changeset 71657 0f98a7c366ed
parent 62828 3fee575c9dce
child 73581 cd84e58aed26
permissions -rwxr-xr-x
avoid jdk-11.0.6+10: it shows problem "S8217731: Font rendering and glyph spacing changed from jdk-8 to jdk-11" https://bugs.openjdk.java.net/browse/JDK-8217731 even though the changelog claims to have resolved this;

#!/usr/bin/env bash
#
# Author: Markus Wenzel, TU Muenchen
#
# DESCRIPTION: get values from Isabelle settings environment


## diagnostics

PRG="$(basename "$0")"

function usage()
{
  echo
  echo "Usage: isabelle $PRG [OPTIONS] [VARNAMES ...]"
  echo
  echo "  Options are:"
  echo "    -a           display complete environment"
  echo "    -b           print values only (doesn't work for -a)"
  echo "    -d FILE      dump complete environment to FILE"
  echo "                 (null terminated entries)"
  echo
  echo "  Get value of VARNAMES from the Isabelle settings."
  echo
  exit 1
}


## process command line

# options

ALL=""
BASE=""
DUMP=""

while getopts "abd:" OPT
do
  case "$OPT" in
    a)
      ALL=true
      ;;
    b)
      BASE=true
      ;;
    d)
      DUMP="$OPTARG"
      ;;
    \?)
      usage
      ;;
  esac
done

shift $(($OPTIND - 1))


# args

[ -z "$ALL" -a -z "$DUMP" -a "$#" -eq 0 ] && usage
[ -n "$ALL" -a "$#" -ne 0 ] && usage


## main

if [ -n "$ALL" ]; then
  env
else
  for VAR in "$@"
  do
    if [ -n "$BASE" ]; then
      eval "echo \$$VAR"
    else
      eval "echo $VAR=\$$VAR"
    fi
  done
fi

if [ -n "$DUMP" ]; then
  export PATH_JVM="$(platform_path "$PATH")"
  exec perl -w -e 'for $key (keys %ENV) { print $key, "=", $ENV{$key}, "\x00"; }' > "$DUMP"
fi