1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-31 12:13:10 +00:00

sh: Prepend "$0: " to error messages if there is no command name.

This commit is contained in:
Jilles Tjoelker 2014-11-22 23:28:41 +00:00
parent f28c40aee0
commit fafeab4393
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=274899
2 changed files with 4 additions and 0 deletions

View File

@ -139,6 +139,8 @@ vwarning(const char *msg, va_list ap)
{ {
if (commandname) if (commandname)
outfmt(out2, "%s: ", commandname); outfmt(out2, "%s: ", commandname);
else if (arg0)
outfmt(out2, "%s: ", arg0);
doformat(out2, msg, ap); doformat(out2, msg, ap);
out2fmt_flush("\n"); out2fmt_flush("\n");
} }

View File

@ -1879,6 +1879,8 @@ synerror(const char *msg)
{ {
if (commandname) if (commandname)
outfmt(out2, "%s: %d: ", commandname, startlinno); outfmt(out2, "%s: %d: ", commandname, startlinno);
else if (arg0)
outfmt(out2, "%s: ", arg0);
outfmt(out2, "Syntax error: %s\n", msg); outfmt(out2, "Syntax error: %s\n", msg);
error((char *)NULL); error((char *)NULL);
} }