summaryrefslogtreecommitdiff
path: root/src/function.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2018-08-04 12:20:11 -0400
committerPaul Smith <psmith@gnu.org>2018-08-04 12:37:19 -0400
commitfa937343f5e0c8ea131d321118b31621413ab1d2 (patch)
treec960bee5ccdae8d0f12ea0acef91db4b9544c218 /src/function.c
parent3112c8799358cb5d051e0b63d0e916357169942c (diff)
downloadmake-git-fa937343f5e0c8ea131d321118b31621413ab1d2.tar.gz
Clean up errors for invalid commands and add regression tests.
* src/function.c (func_shell_base): Use error() instead of recreating the error output. * src/job.c (exec_command): Show more standard error messages. * src/load.c (unload_file): Fix whitespace in the error message. * tests/scripts/features/errors: Add tests for starting non- existent commands and new error message formats. * tests/scripts/features/output-sync: New error message formats. * tests/scripts/functions/shell: Ditto.
Diffstat (limited to 'src/function.c')
-rw-r--r--src/function.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/function.c b/src/function.c
index 12e0ef2f..4602ebb2 100644
--- a/src/function.c
+++ b/src/function.c
@@ -1699,7 +1699,6 @@ func_shell_base (char *o, char **argv, int trim_newlines)
FILE *fpipe;
#endif
char **command_argv = NULL;
- const char *error_prefix;
char **envp;
int pipedes[2];
pid_t pid;
@@ -1739,17 +1738,6 @@ func_shell_base (char *o, char **argv, int trim_newlines)
envp = environ;
- /* For error messages. */
- if (reading_file && reading_file->filenm)
- {
- char *p = alloca (strlen (reading_file->filenm)+11+4);
- sprintf (p, "%s:%lu: ", reading_file->filenm,
- reading_file->lineno + reading_file->offset);
- error_prefix = p;
- }
- else
- error_prefix = "";
-
/* Set up the output in case the shell writes something. */
output_start ();
@@ -1760,7 +1748,7 @@ func_shell_base (char *o, char **argv, int trim_newlines)
fpipe = msdos_openpipe (pipedes, &pid, argv[0]);
if (pipedes[0] < 0)
{
- perror_with_name (error_prefix, "pipe");
+ OS (error, reading_file, "pipe: %s", strerror (errno));
pid = -1;
goto done;
}
@@ -1774,7 +1762,7 @@ func_shell_base (char *o, char **argv, int trim_newlines)
{
/* Open of the pipe failed, mark as failed execution. */
shell_completed (127, 0);
- perror_with_name (error_prefix, "pipe");
+ OS (error, reading_file, "pipe: %s", strerror (errno));
pid = -1;
goto done;
}
@@ -1782,7 +1770,7 @@ func_shell_base (char *o, char **argv, int trim_newlines)
#else
if (pipe (pipedes) < 0)
{
- perror_with_name (error_prefix, "pipe");
+ OS (error, reading_file, "pipe: %s", strerror (errno));
pid = -1;
goto done;
}
@@ -1801,7 +1789,10 @@ func_shell_base (char *o, char **argv, int trim_newlines)
}
if (pid < 0)
- goto done;
+ {
+ shell_completed (127, 0);
+ goto done;
+ }
#endif
{