From a6dae403e6fda358b68b0c91d7232ae9cc11cc4b Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 25 Oct 2019 17:29:56 +0200 Subject: [PATCH] formatter: accept the formatted result also upon a nonzero exit status For a nonzero exit status of the formatting program, report on the status bar that the program "complained", but read in the (probably) reformatted text anyway -- it can be easily undone with M-U. Only report failure when the intended program could not be run. This fixes https://savannah.gnu.org/bugs/?57105. --- src/text.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/text.c b/src/text.c index 506242bc..07d26ad5 100644 --- a/src/text.c +++ b/src/text.c @@ -2576,7 +2576,7 @@ const char *treat(char *tempfile_name, char *theprogram, bool spelling) execvp(arguments[0], arguments); /* Terminate the child if the program is not found. */ - exit(1); + exit(9); } else if (thepid < 0) return _("Could not fork"); @@ -2592,8 +2592,10 @@ const char *treat(char *tempfile_name, char *theprogram, bool spelling) doupdate(); } - if (!WIFEXITED(program_status) || WEXITSTATUS(program_status) != 0) + if (!WIFEXITED(program_status) || WEXITSTATUS(program_status) > 2) return invocation_error(theprogram); + else if (WEXITSTATUS(program_status) != 0) + statusline(ALERT, _("The invoked program complained")); /* Stat the temporary file again. */ stat(tempfile_name, &fileinfo);