`mutt_system()` returns int, so check accordingly.
Also, make sure we log if any calls fail.
else
{
/* interactive command */
- if (mutt_system(command) || (entry->needsterminal && option(OPT_WAIT_KEY)))
+ int rc = mutt_system(command);
+ if (rc == -1)
+ mutt_debug(1, "Error running \"%s\"!", command);
+
+ if ((rc != 0) || (entry->needsterminal && option(OPT_WAIT_KEY)))
mutt_any_key_to_continue(NULL);
}
}
}
else
{
- if (mutt_system(command) || option(OPT_WAIT_KEY))
+ int rc = mutt_system(command);
+ if (rc == -1)
+ mutt_debug(1, "Error running \"%s\"!", command);
+
+ if ((rc != 0) || option(OPT_WAIT_KEY))
mutt_any_key_to_continue(NULL);
}
mutt_window_clearline(MuttMessageWindow, 0);
mutt_endwin(NULL);
fflush(stdout);
- if (mutt_system(buf) != 0 || option(OPT_WAIT_KEY))
+ int rc = mutt_system(buf);
+ if (rc == -1)
+ mutt_debug(1, "Error running \"%s\"!", buf);
+
+ if ((rc != 0) || option(OPT_WAIT_KEY))
mutt_any_key_to_continue(NULL);
mutt_buffy_check(true);
}
mutt_debug(2, "Executing preconnect: %s\n", Preconnect);
rc = mutt_system(Preconnect);
mutt_debug(2, "Preconnect result: %d\n", rc);
- if (rc)
+ if (rc != 0)
{
save_errno = errno;
mutt_perror(_("Preconnect command failed."));
mutt_endwin(NULL);
mutt_expand_file_fmt(cmd, sizeof(cmd), editor, data);
- if (mutt_system(cmd))
+ if (mutt_system(cmd) != 0)
{
mutt_error(_("Error running \"%s\"!"), cmd);
mutt_sleep(2);
{
char cmd[LONG_STRING];
menu_status_line(cmd, sizeof(cmd), menu, NONULL(NewMailCommand));
- mutt_system(cmd);
+ if (mutt_system(cmd) != 0)
+ mutt_error(_("Error running \"%s\"!"), cmd);
}
break;
}
{
char cmd[LONG_STRING];
menu_status_line(cmd, sizeof(cmd), menu, NONULL(NewMailCommand));
- mutt_system(cmd);
+ if (mutt_system(cmd) != 0)
+ mutt_error(_("Error running \"%s\"!"), cmd);
}
}
}
cctx.signas = PgpSignAs;
mutt_pgp_command(cmd, sizeof(cmd), &cctx, PgpImportCommand);
- mutt_system(cmd);
+ if (mutt_system(cmd) != 0)
+ mutt_debug(1, "Error running \"%s\"!", cmd);
}
void pgp_invoke_getkeys(struct Address *addr)
if (!isendwin())
mutt_message(_("Fetching PGP key..."));
- mutt_system(cmd);
+ if (mutt_system(cmd) != 0)
+ mutt_debug(1, "Error running \"%s\"!", cmd);
if (!isendwin())
mutt_clear_error();
{
char cmd[LONG_STRING];
menu_status_line(cmd, sizeof(cmd), rd.index, NONULL(NewMailCommand));
- mutt_system(cmd);
+ if (mutt_system(cmd) != 0)
+ mutt_error(_("Error running \"%s\"!"), cmd);
}
}
}
if (!option(OPT_NO_CURSES))
mutt_endwin(NULL);
- if ((i = mutt_system(cmd)))
+ i = mutt_system(cmd);
+ if (i != 0)
{
fprintf(stderr, _("Error sending message, child exited %d.\n"), i);
if (!option(OPT_NO_CURSES))
len = mutt_strlen(test_command) + STRING;
safe_realloc(&test_command, len);
rfc1524_expand_command(a, a->filename, type, test_command, len);
- if (mutt_system(test_command))
+ if (mutt_system(test_command) != 0)
{
/* a non-zero exit code means test failed */
found = false;
#include <sys/types.h>
#include <sys/wait.h>
+/**
+ * mutt_system - Run an external command
+ * @param cmd Command and argments
+ * @retval -1 Error
+ * @retval >=0 Success (command's return code)
+ *
+ * Fork and run an external command with arguments.
+ *
+ * @note This function won't return until the command finishes.
+ */
int mutt_system(const char *cmd)
{
int rc = -1;