lib/Tools/rmfifo
author wenzelm
Thu, 23 Oct 2008 13:52:27 +0200
changeset 28671 ed6681dd35d8
parent 28650 a7ba12e0d3b7
child 29143 72c960b2b83e
permissions -rwxr-xr-x
thread-safe version, with non-critical evaluation; do not re-evaluate failed result; misc tuning;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28063
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
     2
#
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
     3
# $Id$
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
     4
# Author: Makarius
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
     5
#
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
     6
# DESCRIPTION: remove named pipe
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
     7
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
     8
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
     9
PRG="$(basename "$0")"
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    10
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    11
function usage()
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    12
{
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    13
  echo
28650
a7ba12e0d3b7 tuned usage line;
wenzelm
parents: 28063
diff changeset
    14
  echo "Usage: isabelle $PRG NAME"
28063
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    15
  echo
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    16
  echo "  Remove an unused named pipe, after producing dummy output"
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    17
  echo "  to unblock the reader (blocks if no reader present)."
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    18
  echo
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    19
  exit 1
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    20
}
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    21
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    22
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    23
## main
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    24
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    25
[ "$#" != 1 ] && usage
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    26
FIFO="$1"; shift
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    27
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    28
if [ -p "$FIFO" ]; then
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    29
  echo -n "" >"$FIFO" && rm -f "$FIFO"
3533485fc7b8 IsabelleSystem.mk_fifo, IsabelleSystem.rm_fifo;
wenzelm
parents:
diff changeset
    30
fi