Fixed write_pipe bug

This commit is contained in:
Jesse Gardner 2021-04-15 19:05:53 -07:00
parent 62e36d07e9
commit 5ba009a885
1 changed files with 5 additions and 4 deletions

View File

@ -105,20 +105,21 @@ write_pipe ()
# OUTPUT: None
# PARAMETERS: $1: '0' if passing another parameter(s), '1' if writing to
# stdin instead.
# $2 and on: If $1 is 0, this is the information write_pipe will
# write as "$*"
# $2 and on: If $1 is 0, write_pipe will write the remaining parameters
#=========================================================================#
{
# We put a + at the beginning of every line to let read_pipe work in a
# non-blocking manner
if (($1)); then
local line
if (($1)); then
while IFS= read -r line; do
echo "+$line" >&3
done
else
shift
echo "+$*" >&3
echo "$@" | while IFS= read -r line; do
echo "+$line" >&3
done
fi
return 0
}