Browse Source

[monojob] Allow monojob to be completely silent

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
89a354d553
1 changed files with 11 additions and 7 deletions
  1. 11
    7
      src/core/monojob.c

+ 11
- 7
src/core/monojob.c View File

53
 /**
53
 /**
54
  * Wait for single foreground job to complete
54
  * Wait for single foreground job to complete
55
  *
55
  *
56
- * @v string		Job description to display
56
+ * @v string		Job description to display, or NULL to be silent
57
  * @ret rc		Job final status code
57
  * @ret rc		Job final status code
58
  */
58
  */
59
 int monojob_wait ( const char *string ) {
59
 int monojob_wait ( const char *string ) {
67
 	unsigned int percentage;
67
 	unsigned int percentage;
68
 	int shown_percentage = 0;
68
 	int shown_percentage = 0;
69
 
69
 
70
-	printf ( "%s...", string );
70
+	if ( string )
71
+		printf ( "%s...", string );
71
 	monojob_rc = -EINPROGRESS;
72
 	monojob_rc = -EINPROGRESS;
72
 	last_progress = currticks();
73
 	last_progress = currticks();
73
 	while ( monojob_rc == -EINPROGRESS ) {
74
 	while ( monojob_rc == -EINPROGRESS ) {
83
 			}
84
 			}
84
 		}
85
 		}
85
 		elapsed = ( currticks() - last_progress );
86
 		elapsed = ( currticks() - last_progress );
86
-		if ( elapsed >= TICKS_PER_SEC ) {
87
+		if ( string && ( elapsed >= TICKS_PER_SEC ) ) {
87
 			if ( shown_percentage )
88
 			if ( shown_percentage )
88
 				printf ( "\b\b\b\b    \b\b\b\b" );
89
 				printf ( "\b\b\b\b    \b\b\b\b" );
89
 			job_progress ( &monojob, &progress );
90
 			job_progress ( &monojob, &progress );
106
 	if ( shown_percentage )
107
 	if ( shown_percentage )
107
 		printf ( "\b\b\b\b    \b\b\b\b" );
108
 		printf ( "\b\b\b\b    \b\b\b\b" );
108
 
109
 
109
-	if ( rc ) {
110
-		printf ( " %s\n", strerror ( rc ) );
111
-	} else {
112
-		printf ( " ok\n" );
110
+	if ( string ) {
111
+		if ( rc ) {
112
+			printf ( " %s\n", strerror ( rc ) );
113
+		} else {
114
+			printf ( " ok\n" );
115
+		}
113
 	}
116
 	}
117
+
114
 	return rc;
118
 	return rc;
115
 }
119
 }

Loading…
Cancel
Save