From ecd5034aca6029c1900f8d681fafb2f5177a7f0b Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Mon, 14 May 2018 19:11:03 +0200 Subject: make: improve blogc output formatting --- src/blogc-make/exec.c | 59 ++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/src/blogc-make/exec.c b/src/blogc-make/exec.c index 49c46a2..df28e5a 100644 --- a/src/blogc-make/exec.c +++ b/src/blogc-make/exec.c @@ -308,10 +308,6 @@ bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *global_variables, bc_trie_t *local_varia int rv = bm_exec_command(cmd, input->str, &out, &err, &error); - if (err != NULL) { - fprintf(stderr, "%s", err); - } - if (error != NULL) { bc_error_print(error, "blogc-make"); free(cmd); @@ -322,35 +318,36 @@ bm_exec_blogc(bm_ctx_t *ctx, bc_trie_t *global_variables, bc_trie_t *local_varia return 3; } - if (rv != 0) { - if (ctx->verbose) { - fprintf(stderr, - "blogc-make: error: Failed to execute command.\n" - "\n" - "STATUS CODE: %d\n", rv); - if (input->len > 0) { - fprintf(stderr, "\nSTDIN:\n" - "----------------------------->8-----------------------------\n" - "%s\n" - "----------------------------->8-----------------------------\n", - bc_str_strip(input->str)); - } - if (out != NULL) { - fprintf(stderr, "\nSTDOUT:\n" - "----------------------------->8-----------------------------\n" - "%s\n" - "----------------------------->8-----------------------------\n", - bc_str_strip(out)); - } + if (rv != 0 && ctx->verbose) { + fprintf(stderr, + "blogc-make: error: Failed to execute command.\n" + "\n" + "STATUS CODE: %d\n", rv); + if (input->len > 0) { + fprintf(stderr, "\nSTDIN:\n" + "----------------------------->8-----------------------------\n" + "%s\n" + "----------------------------->8-----------------------------\n", + bc_str_strip(input->str)); } - else { - fprintf(stderr, - "blogc-make: error: Failed to execute command (%d)", rv); - if (err != NULL) { - fprintf(stderr, ":\n%s", bc_str_strip(err)); - } - fprintf(stderr, "\n"); + if (out != NULL) { + fprintf(stderr, "\nSTDOUT:\n" + "----------------------------->8-----------------------------\n" + "%s\n" + "----------------------------->8-----------------------------\n", + bc_str_strip(out)); + } + if (err != NULL) { + fprintf(stderr, "\nSTDERR:\n" + "----------------------------->8-----------------------------\n" + "%s\n" + "----------------------------->8-----------------------------\n", + bc_str_strip(err)); } + fprintf(stderr, "\n"); + } + else if (err != NULL) { + fprintf(stderr, "%s\n", err); } bc_string_free(input, true); -- cgit v1.2.3-18-g5258