试图在 bash 中读取 fifo。为什么我会出错?
pipe="./$1"
trap "rm -f $pipe" EXIT
if [[ ! -p $pipe ]]; then
mkfifo $pipe
fi
while true
do
if read line <$pipe; then
if "$line" == 'exit' || "$line" == 'EXIT' ; then
break
elif ["$line" == 'yes']; then
echo "YES"
else
echo $line
fi
fi
done
echo "Reader exiting"
我得到的错误:
./sh.sh: line 12: [: missing `]' ./sh.sh: line 14: [HelloWorld: command not found
从其他 shell 运行并打印时HelloWorld