revert to pipe - behaves better

This commit is contained in:
mattijs
2008-09-26 13:11:31 +01:00
parent 1ae6914a8e
commit e548936cb0

View File

@ -137,6 +137,16 @@ done
# is returned and not of colouring pipe. # is returned and not of colouring pipe.
set -o pipefail set -o pipefail
# Define function to colour output by argument 1
colourPipe(){
if [ "$1" ]; then
(while read line; do setterm -foreground $1; echo "$line" ; done; setterm -foreground default)
else
cat
fi
}
colourIndex=0 colourIndex=0
while : while :
@ -156,14 +166,14 @@ do
if lockfile -r0 "$lockFile" 2>/dev/null; then if lockfile -r0 "$lockFile" 2>/dev/null; then
if [ "$WM_COLOURS" ]; then if [ "$WM_COLOURS" ]; then
# Set colour # Set colour
colourString=`setterm -foreground ${colours[$colourIndex]}` colour="${colours[$colourIndex]}"
if [ "$host" = "$HOST" ]; then if [ "$host" = "$HOST" ]; then
eval $* 2>&1 | sed -e "s/^/$colourString/" eval $* 2>&1 | colourPipe "$colour"
elif [ -n "$JOB_ID" ]; then elif [ -n "$JOB_ID" ]; then
qrsh -inherit -v PWD $host "$rcmd" qrsh -inherit -v PWD $host "$rcmd"
else else
ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | sed -e "s/^/$colourString/" ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 | colourPipe "$colour"
fi fi
retval=$? retval=$?
else else