lib/scripts/feeder.pl
author wenzelm
Wed, 03 Nov 2010 21:53:56 +0100
changeset 40335 3e4bb6e7c3ca
parent 39580 05daab5782f6
child 41616 aa002926cbf1
permissions -rw-r--r--
feeder: treat header as escaped utf8 to allow initial ML text to refer to non-ASCII file/directory names (e.g. "Documents/" on Chinese Ubuntu);

#
# Author: Markus Wenzel, TU Muenchen
#
# feeder.pl - feed isabelle session
#

# args

($head, $emitpid, $quit, $tail) = @ARGV;


# setup signal handlers

sub hangup { exit(0); }
$SIG{'HUP'} = "hangup";
$SIG{'INT'} = "IGNORE";


# main

#buffer lines
$| = 1;


$emitpid && (print $$, "\n");

if ($head) {
  utf8::encode($head);
  $head =~ s/([\x80-\xff])/\\${\(ord($1))}/g;
  print $head, "\n";
}

if (!$quit) {
  while (<STDIN>) {
    print;
  }
}

$tail && (print "$tail", "\n");


# wait forever

close STDOUT;
sleep;