From 802b70f5eee8cc0369316f4e5c595ee96199c6fa Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Mon, 17 Jun 2024 00:14:34 +0100 Subject: [PATCH] Add option to discard command output --- src/common/shell/commander/commander.c | 2 +- src/common/shell/commander/commander.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/shell/commander/commander.c b/src/common/shell/commander/commander.c index 4091e78..59caec3 100644 --- a/src/common/shell/commander/commander.c +++ b/src/common/shell/commander/commander.c @@ -101,7 +101,7 @@ internal inline CMDError get_command_output(FILE *fp, } strcat(out_buf, out); - } else { + } else if (out_handling == SHELL_OUTPUT_PRINT) { printf("%s", out); } } diff --git a/src/common/shell/commander/commander.h b/src/common/shell/commander/commander.h index 8c9051a..c2f543a 100644 --- a/src/common/shell/commander/commander.h +++ b/src/common/shell/commander/commander.h @@ -10,11 +10,12 @@ extern "C" { #endif // __cplusplus #define CMD_NO_EXIT(ERR) \ - ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE}) + ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR}) #define wapp_shell_commander_execute(HANDLE_OUTPUT, OUT_BUF, BUF_SIZE, ...) \ run_command(HANDLE_OUTPUT, OUT_BUF, BUF_SIZE, __VA_ARGS__, NULL) typedef enum { + SHELL_OUTPUT_DISCARD, SHELL_OUTPUT_PRINT, SHELL_OUTPUT_CAPTURE, } CMDOutHandling;