From e548936cb035df10b9423cef59b9b4c81cdd7551 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs@hunt.opencfd.co.uk> Date: Fri, 26 Sep 2008 13:11:31 +0100 Subject: [PATCH] revert to pipe - behaves better --- wmake/wmakeScheduler | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/wmake/wmakeScheduler b/wmake/wmakeScheduler index bf9bfc914bd..2a2ed0fd765 100755 --- a/wmake/wmakeScheduler +++ b/wmake/wmakeScheduler @@ -137,6 +137,16 @@ done # is returned and not of colouring pipe. 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 while : @@ -156,14 +166,14 @@ do if lockfile -r0 "$lockFile" 2>/dev/null; then if [ "$WM_COLOURS" ]; then # Set colour - colourString=`setterm -foreground ${colours[$colourIndex]}` + colour="${colours[$colourIndex]}" if [ "$host" = "$HOST" ]; then - eval $* 2>&1 | sed -e "s/^/$colourString/" + eval $* 2>&1 | colourPipe "$colour" elif [ -n "$JOB_ID" ]; then qrsh -inherit -v PWD $host "$rcmd" 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 retval=$? else -- GitLab