lib/scripts/feeder
author kleing
Mon, 21 Jun 2004 10:25:57 +0200
changeset 14981 e73f8140af78
parent 13076 70704dd48bd5
child 15847 c05c7670f166
permissions -rwxr-xr-x
Merged in license change from Isabelle2004

#!/usr/bin/env bash
#
# $Id$
# Author: Markus Wenzel, TU Muenchen
#
# feeder - feed isabelle session


## diagnostics

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

function usage()
{
  echo
  echo "Usage: $PRG [OPTIONS]"
  echo
  echo "  Options are:"
  echo "    -h TEXT      head text"
  echo "    -p           emit my pid"
  echo "    -q           do not pipe stdin"
  echo "    -t TEXT      tail text"
  echo
  echo "  Output texts (pid, head, stdin, tail), then wait to be terminated."
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}


## process command line

# options

HEAD=""
EMITPID=""
QUIT=""
TAIL=""

while getopts "h:pqt:" OPT
do
  case "$OPT" in
    h)
      HEAD="$OPTARG"
      ;;
    p)
      EMITPID=true
      ;;
    q)
      QUIT=true
      ;;
    t)
      TAIL="$OPTARG"
      ;;
    \?)
      usage
      ;;
  esac
done

shift $(($OPTIND - 1))


# args

[ "$#" -ne 0 ] && { echo "Bad args: $*"; usage; }



## main

#set by configure
AUTO_PERL=/usr/bin/perl

exec "$AUTO_PERL" -w "$DIR"/feeder.pl "$HEAD" "$EMITPID" "$QUIT" "$TAIL"