When I use tee
to pipe stdout directly to a "specific block of code" (which then writes the modified data to a file), I always get the full complement of exptected output lines in the file.
However, when I tee
the same data to a process >("same block of code")
, it can drop up to 4 lines from the output. This number varies; sometimes it writes all the lines.
How can I get around this issue, and why is it only happening in the >( process )
?
More info: I am 'tee'-ing to 2 process-substitutions and also to normal stdout pipe when this line dropping occurs.
using GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu) on Ubuntu 10.04.2 LTS.
Here is the actual script. The second process-substitution is the one in question, the one beginning with >(tr $'\x60' $X01
#
# Run 'locate' and direct the output to a temp file
errflag=""
locitmct=0 # Count of located items
columns=4 # The number of columns in the main dialog
colmnb=0 # Column number (NB: columns 1 and 2 are processed together)
X01=$'\x01'
eval locate $zenargs |tee \
>(zenity --progress --pulsate --auto-close) \
>(tr $'\x60' $X01 \
|sed -n "s/^\(.*\/\)\(.*\)/\1\2\n\2\n\1/p" \
|while IFS= read -r line ; do \
#
#
# process the data
#
#
done > "$listf" )\
>/dev/null
#
cat "$listf"
#
tee
finishes sending it's last data, it exits and passes control to the followingcat
.. However my >(process) is still processing the last piece of data... I've triedwait
but it has no effect. I suppose that is because process substitution is not a "normal" child process... btw,sleep 1
works, but that's just guesswork and what if it takes 10 seconds longer?.. there must be anoter way..