equal
deleted
inserted
replaced
1 #!/usr/bin/env bash |
|
2 # |
|
3 # Author: Makarius |
|
4 # |
|
5 # DESCRIPTION: create named pipe |
|
6 |
|
7 |
|
8 PRG="$(basename "$0")" |
|
9 |
|
10 function usage() |
|
11 { |
|
12 echo |
|
13 echo "Usage: isabelle $PRG [SUFFIX]" |
|
14 echo |
|
15 echo " Create a temporary named pipe and return its name." |
|
16 echo |
|
17 exit 1 |
|
18 } |
|
19 |
|
20 function fail() |
|
21 { |
|
22 echo "$1" >&2 |
|
23 exit 2 |
|
24 } |
|
25 |
|
26 |
|
27 ## main |
|
28 |
|
29 SUFFIX="" |
|
30 [ "$#" != 0 ] && { SUFFIX="-$1"; shift; } |
|
31 |
|
32 [ "$#" != 0 ] && usage |
|
33 |
|
34 ID="$PPID" |
|
35 [ "$ID" = 0 -o "$ID" = 1 ] && ID="$$" # Cygwin workaround |
|
36 |
|
37 FIFO="/tmp/isabelle-fifo${ID}${SUFFIX}" |
|
38 |
|
39 mkfifo -m 600 "$FIFO" || fail "Failed to create fifo: $FIFO" |
|
40 echo "$FIFO" |
|