[pacman-dev] [PATCH 1/8] pacman: Make sure delayed warnings/errors are shown the same

Olivier Brunel jjk at jjacky.com
Mon Dec 2 15:45:13 EST 2013


When delayed until after a progress operation, they wouldn't be in colors,
and be sent to stdout instead of stderr.

Signed-off-by: Olivier Brunel <jjk at jjacky.com>
---
 src/pacman/callback.c | 2 +-
 src/pacman/util.c     | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index a181fa5..c412f6f 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -529,7 +529,7 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent,
 		alpm_list_t *i = NULL;
 		on_progress = 0;
 		for(i = output; i; i = i->next) {
-			fputs((const char *)i->data, stdout);
+			fputs((const char *)i->data, stderr);
 		}
 		fflush(stdout);
 		FREELIST(output);
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 23eea98..4877cc3 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1593,10 +1593,12 @@ int pm_vasprintf(char **string, alpm_loglevel_t level, const char *format, va_li
 	/* print a prefix to the message */
 	switch(level) {
 		case ALPM_LOG_ERROR:
-			pm_asprintf(string, _("error: %s"), msg);
+			pm_asprintf(string, "%s%s%s%s", config->colstr.err, _("error: "),
+					config->colstr.nocolor, msg);
 			break;
 		case ALPM_LOG_WARNING:
-			pm_asprintf(string, _("warning: %s"), msg);
+			pm_asprintf(string, "%s%s%s%s", config->colstr.warn, _("warning: "),
+					config->colstr.nocolor, msg);
 			break;
 		case ALPM_LOG_DEBUG:
 			pm_asprintf(string, "debug: %s", msg);
-- 
1.8.4.2



More information about the pacman-dev mailing list