Ensure stderr is piped to stdout to capture errors in output

This commit is contained in:
Abdelrahman Said 2024-06-17 00:18:27 +01:00
parent 8a91a0ec6b
commit 8ed372d938
2 changed files with 3 additions and 3 deletions

View File

@ -12,7 +12,7 @@ extern "C" {
#define CMD_NO_EXIT(ERR) \ #define CMD_NO_EXIT(ERR) \
((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR}) ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR})
#define wapp_shell_commander_execute(HANDLE_OUTPUT, OUT_BUF, BUF_SIZE, ...) \ #define wapp_shell_commander_execute(HANDLE_OUTPUT, OUT_BUF, BUF_SIZE, ...) \
run_command(HANDLE_OUTPUT, OUT_BUF, BUF_SIZE, __VA_ARGS__, NULL) run_command(HANDLE_OUTPUT, OUT_BUF, BUF_SIZE, __VA_ARGS__, "2>&1", NULL)
typedef enum { typedef enum {
SHELL_OUTPUT_DISCARD, SHELL_OUTPUT_DISCARD,

View File

@ -17,8 +17,8 @@ TestFuncResult test_commander_cmd_success(void) {
} }
TestFuncResult test_commander_cmd_failure(void) { TestFuncResult test_commander_cmd_failure(void) {
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, 0, CMDResult result =
"grep", "2>&1"); wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, 0, "grep");
bool failed = result.exited && result.exit_code != EXIT_SUCCESS && bool failed = result.exited && result.exit_code != EXIT_SUCCESS &&
result.error == SHELL_ERR_NO_ERROR; result.error == SHELL_ERR_NO_ERROR;