From fafeab43932d054c05f63feb9f8bf2ef33f292f7 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 22 Nov 2014 23:28:41 +0000 Subject: [PATCH] sh: Prepend "$0: " to error messages if there is no command name. --- bin/sh/error.c | 2 ++ bin/sh/parser.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bin/sh/error.c b/bin/sh/error.c index c76a9dc6576..96a0092d5bb 100644 --- a/bin/sh/error.c +++ b/bin/sh/error.c @@ -139,6 +139,8 @@ vwarning(const char *msg, va_list ap) { if (commandname) outfmt(out2, "%s: ", commandname); + else if (arg0) + outfmt(out2, "%s: ", arg0); doformat(out2, msg, ap); out2fmt_flush("\n"); } diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 7fae29eb7c5..00483143753 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -1879,6 +1879,8 @@ synerror(const char *msg) { if (commandname) outfmt(out2, "%s: %d: ", commandname, startlinno); + else if (arg0) + outfmt(out2, "%s: ", arg0); outfmt(out2, "Syntax error: %s\n", msg); error((char *)NULL); }