2

This question already has an answer here:

I tried using the -f flag to test if a named pipe is present

if [[ ! -f "$fifo" ]]; then
  echo 'There should be a fifo.lock file in the dir.' > /dev/stderr
  return 0;
fi

this check does not seem correct. So perhaps a named-pipe is not a file, but something else?

marked as duplicate by Christopher, Jeff Schaller bash Jun 4 at 22:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

You need to use the -p construct to see if the file is of type named pipe. It works with the standard test [ (POSIX compliant) and the extended test operators [[ ( bash/zsh specific )

if [[ -p "$fifo" ]]; then
    printf '%s is a named pipe' "$fifo"
fi

From the man pages of bash

-p file

True if file exists and is a named pipe (FIFO).

or use the file command with the -b to just print the type information without the filename. The -b might not be POSIX compliant

if [ $(file -b "$fifo") = "fifo (named pipe)" ]; then
   printf '%s is a named pipe' "$fifo"
fi

Without the -b, one could do

type=$(file "$fifo")
if [ "${type##*: }" = "fifo (named pipe)" ]; then