Added tmpfifo command to the file tree.

This commit is contained in:
Olivier Poirier 2023-09-28 22:30:14 -07:00
parent 048764eeb7
commit 795d4b98d8
1 changed files with 20 additions and 0 deletions

20
primitives/tmpfifo Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
# Creates a fifo named after the first argument.
FIFODIR="/tmp/fifo"
mkdir -p "$FIFODIR"
if [ $? != "0" ] ; then
echo "Couldn't make FIFO directory: $FIFODIR" >&2
else
if [ "$1" = "" ] ; then
NAME="fifo"
else
NAME="$1"
fi
NUMBER=1
while [ -e "$FIFODIR/$NAME-$NUMBER" ] ; do
NUMBER=$(($NUMBER+1))
done
mkfifo "$FIFODIR/$NAME-$NUMBER"
echo "$FIFODIR/$NAME-$NUMBER"
fi