Explorar el Código

[monojob] Allow monojob to be completely silent

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown hace 12 años
padre
commit
89a354d553
Se han modificado 1 ficheros con 11 adiciones y 7 borrados
  1. 11
    7
      src/core/monojob.c

+ 11
- 7
src/core/monojob.c Ver fichero

@@ -53,7 +53,7 @@ struct interface monojob = INTF_INIT ( monojob_intf_desc );
53 53
 /**
54 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 57
  * @ret rc		Job final status code
58 58
  */
59 59
 int monojob_wait ( const char *string ) {
@@ -67,7 +67,8 @@ int monojob_wait ( const char *string ) {
67 67
 	unsigned int percentage;
68 68
 	int shown_percentage = 0;
69 69
 
70
-	printf ( "%s...", string );
70
+	if ( string )
71
+		printf ( "%s...", string );
71 72
 	monojob_rc = -EINPROGRESS;
72 73
 	last_progress = currticks();
73 74
 	while ( monojob_rc == -EINPROGRESS ) {
@@ -83,7 +84,7 @@ int monojob_wait ( const char *string ) {
83 84
 			}
84 85
 		}
85 86
 		elapsed = ( currticks() - last_progress );
86
-		if ( elapsed >= TICKS_PER_SEC ) {
87
+		if ( string && ( elapsed >= TICKS_PER_SEC ) ) {
87 88
 			if ( shown_percentage )
88 89
 				printf ( "\b\b\b\b    \b\b\b\b" );
89 90
 			job_progress ( &monojob, &progress );
@@ -106,10 +107,13 @@ int monojob_wait ( const char *string ) {
106 107
 	if ( shown_percentage )
107 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 118
 	return rc;
115 119
 }

Loading…
Cancelar
Guardar