mirror of
https://github.com/ipxe/ipxe
synced 2025-12-14 16:01:38 +03:00
[monojob] Allow monojob to be completely silent
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -53,7 +53,7 @@ struct interface monojob = INTF_INIT ( monojob_intf_desc );
|
|||||||
/**
|
/**
|
||||||
* Wait for single foreground job to complete
|
* 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
|
* @ret rc Job final status code
|
||||||
*/
|
*/
|
||||||
int monojob_wait ( const char *string ) {
|
int monojob_wait ( const char *string ) {
|
||||||
@@ -67,7 +67,8 @@ int monojob_wait ( const char *string ) {
|
|||||||
unsigned int percentage;
|
unsigned int percentage;
|
||||||
int shown_percentage = 0;
|
int shown_percentage = 0;
|
||||||
|
|
||||||
printf ( "%s...", string );
|
if ( string )
|
||||||
|
printf ( "%s...", string );
|
||||||
monojob_rc = -EINPROGRESS;
|
monojob_rc = -EINPROGRESS;
|
||||||
last_progress = currticks();
|
last_progress = currticks();
|
||||||
while ( monojob_rc == -EINPROGRESS ) {
|
while ( monojob_rc == -EINPROGRESS ) {
|
||||||
@@ -83,7 +84,7 @@ int monojob_wait ( const char *string ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elapsed = ( currticks() - last_progress );
|
elapsed = ( currticks() - last_progress );
|
||||||
if ( elapsed >= TICKS_PER_SEC ) {
|
if ( string && ( elapsed >= TICKS_PER_SEC ) ) {
|
||||||
if ( shown_percentage )
|
if ( shown_percentage )
|
||||||
printf ( "\b\b\b\b \b\b\b\b" );
|
printf ( "\b\b\b\b \b\b\b\b" );
|
||||||
job_progress ( &monojob, &progress );
|
job_progress ( &monojob, &progress );
|
||||||
@@ -106,10 +107,13 @@ int monojob_wait ( const char *string ) {
|
|||||||
if ( shown_percentage )
|
if ( shown_percentage )
|
||||||
printf ( "\b\b\b\b \b\b\b\b" );
|
printf ( "\b\b\b\b \b\b\b\b" );
|
||||||
|
|
||||||
if ( rc ) {
|
if ( string ) {
|
||||||
printf ( " %s\n", strerror ( rc ) );
|
if ( rc ) {
|
||||||
} else {
|
printf ( " %s\n", strerror ( rc ) );
|
||||||
printf ( " ok\n" );
|
} else {
|
||||||
|
printf ( " ok\n" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user