dotool/dotoolc

24 lines
627 B
Text
Raw Permalink Normal View History

2022-10-20 15:21:20 +02:00
#!/bin/sh
if [ $# != 0 ]; then
2023-05-11 12:16:22 +02:00
echo 'dotoolc writes its stdin to the pipe being read by dotoold. dotoolc will
exit immediately if the pipe is not being read. The path of the pipe
is $DOTOOL_PIPE else /tmp/dotool-pipe.' >&2
2022-10-20 15:21:20 +02:00
[ "$1" = -h ] || [ "$1" = --help ]; exit
fi
fifo_being_read(){
[ -p "$1" ] && /bin/echo 1<>"$1" >"$1"
}
2023-04-28 17:44:54 +02:00
p="${DOTOOL_PIPE:-/tmp/dotool-pipe}"
2022-10-20 15:21:20 +02:00
if [ -p "$p" ] && ! [ -w "$p" ]; then
2023-01-25 18:47:12 +01:00
printf %s\\n "dotoolc: the pipe does not grant write permission: $p" >&2
2022-10-20 15:21:20 +02:00
exit 1
fi
if ! fifo_being_read "$p"; then
2023-01-25 18:47:12 +01:00
printf %s\\n "dotoolc: no dotoold instance is reading the pipe: $p" >&2
2022-10-20 15:21:20 +02:00
exit 1
fi
2022-10-22 19:38:19 +02:00
exec cat > "$p"