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