Skip to content

Commit

Permalink
[monojob] Allow monojob to be completely silent
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed May 21, 2012
1 parent 944e023 commit 89a354d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/core/monojob.c
Expand Up @@ -53,7 +53,7 @@ struct interface monojob = INTF_INIT ( monojob_intf_desc );
/**
* Wait for single foreground job to complete
*
* @v string Job description to display
* @v string Job description to display, or NULL to be silent
* @ret rc Job final status code
*/
int monojob_wait ( const char *string ) {
Expand All @@ -67,7 +67,8 @@ int monojob_wait ( const char *string ) {
unsigned int percentage;
int shown_percentage = 0;

printf ( "%s...", string );
if ( string )
printf ( "%s...", string );
monojob_rc = -EINPROGRESS;
last_progress = currticks();
while ( monojob_rc == -EINPROGRESS ) {
Expand All @@ -83,7 +84,7 @@ int monojob_wait ( const char *string ) {
}
}
elapsed = ( currticks() - last_progress );
if ( elapsed >= TICKS_PER_SEC ) {
if ( string && ( elapsed >= TICKS_PER_SEC ) ) {
if ( shown_percentage )
printf ( "\b\b\b\b \b\b\b\b" );
job_progress ( &monojob, &progress );
Expand All @@ -106,10 +107,13 @@ int monojob_wait ( const char *string ) {
if ( shown_percentage )
printf ( "\b\b\b\b \b\b\b\b" );

if ( rc ) {
printf ( " %s\n", strerror ( rc ) );
} else {
printf ( " ok\n" );
if ( string ) {
if ( rc ) {
printf ( " %s\n", strerror ( rc ) );
} else {
printf ( " ok\n" );
}
}

return rc;
}

0 comments on commit 89a354d

Please sign in to comment.