From 5ada2c10e3f4c0fe49ba7fe25635488ffd124741 Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 20 Dec 2005 13:38:41 +0000 Subject: [PATCH] 2005-12-20 13:38:41 by steve Force debootstrap output to display properly by truncating long lines. --- xen-create-image | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/xen-create-image b/xen-create-image index b117f90..6e8b5fc 100755 --- a/xen-create-image +++ b/xen-create-image @@ -203,7 +203,7 @@ broadcast = 255.255.255.0 -- http://www.steve.org.uk/ - $Id: xen-create-image,v 1.36 2005-12-20 13:27:03 steve Exp $ + $Id: xen-create-image,v 1.37 2005-12-20 13:38:41 steve Exp $ =cut @@ -1041,18 +1041,49 @@ sub runCommandWithProgress my $output =''; while(1) { - + # + # Wait for input. + # select(undef,undef,undef,.01); + # + # Read output from the command, max 1k. + # if( sysread \*READ,$output,1024 ) { - while( length( $output ) < 80 ) { $output .= " " ; } + # + # If there is more than 80 characters truncate it + # to avoid screen wrap. + # + if ( length( $output ) > 80 ) + { + $output = substr( $output, 0, 70 ); + } + + # + # Padd to exactly 80 characters. + # TODO: Determine TERM width? + while( length( $output ) < 80 ) + { + $output .= " " ; + } + + # + # Remove newlines to avoid weirdness. $output =~ s/\n//g; + + # + # Now rewind cursor to start of line and display + # the text. + # print STDERR "\r"; print STDERR $output; } else { + # + # command finished. + # print STDERR "\rFinished\n\n"; return; }