10555
|
1 |
#!/usr/bin/env bash
|
4501
|
2 |
#
|
|
3 |
# $Id$
|
9789
|
4 |
# Author: Markus Wenzel, TU Muenchen
|
4501
|
5 |
#
|
|
6 |
# feeder - feed isabelle session
|
|
7 |
|
|
8 |
|
|
9 |
## diagnostics
|
|
10 |
|
10512
|
11 |
PRG="$(basename "$0")"
|
|
12 |
DIR="$(dirname "$0")"
|
4501
|
13 |
|
|
14 |
function usage()
|
|
15 |
{
|
|
16 |
echo
|
|
17 |
echo "Usage: $PRG [OPTIONS]"
|
|
18 |
echo
|
|
19 |
echo " Options are:"
|
|
20 |
echo " -h TEXT head text"
|
|
21 |
echo " -p emit my pid"
|
|
22 |
echo " -q do not pipe stdin"
|
|
23 |
echo " -t TEXT tail text"
|
|
24 |
echo
|
|
25 |
echo " Output texts (pid, head, stdin, tail), then wait to be terminated."
|
|
26 |
echo
|
|
27 |
exit 1
|
|
28 |
}
|
|
29 |
|
|
30 |
function fail()
|
|
31 |
{
|
|
32 |
echo "$1" >&2
|
|
33 |
exit 2
|
|
34 |
}
|
|
35 |
|
|
36 |
|
|
37 |
## process command line
|
|
38 |
|
|
39 |
# options
|
|
40 |
|
|
41 |
HEAD=""
|
|
42 |
EMITPID=""
|
|
43 |
QUIT=""
|
|
44 |
TAIL=""
|
|
45 |
|
12111
|
46 |
while getopts "h:pqt:" OPT
|
4501
|
47 |
do
|
|
48 |
case "$OPT" in
|
|
49 |
h)
|
|
50 |
HEAD="$OPTARG"
|
|
51 |
;;
|
|
52 |
p)
|
|
53 |
EMITPID=true
|
|
54 |
;;
|
|
55 |
q)
|
|
56 |
QUIT=true
|
|
57 |
;;
|
|
58 |
t)
|
|
59 |
TAIL="$OPTARG"
|
|
60 |
;;
|
|
61 |
\?)
|
|
62 |
usage
|
|
63 |
;;
|
|
64 |
esac
|
|
65 |
done
|
|
66 |
|
|
67 |
shift $(($OPTIND - 1))
|
|
68 |
|
|
69 |
|
|
70 |
# args
|
|
71 |
|
9789
|
72 |
[ "$#" -ne 0 ] && { echo "Bad args: $*"; usage; }
|
4501
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
## main
|
|
77 |
|
26576
|
78 |
exec perl -w "$DIR"/feeder.pl "$HEAD" "$EMITPID" "$QUIT" "$TAIL"
|