Hi,
This is a small cosmetic patch which fixes something that annoyed me for a long
time: the repetition of the script name in error messages.
Example:
$ cat test.sh
#!/bin/sh
echo ${x:?}
$ dash test.sh
/home/odc/test.sh: 2: /home/odc/test.sh: x: parameter not set or null
With the patch:
$ dash test.sh
/home/odc/test.sh: 2: x: parameter not set or null
This is the same behavior as bash.
diff --git a/src/error.c b/src/error.c
index 728ff88..ed35256 100644
--- a/src/error.c
+++ b/src/error.c
@@ -46,6 +46,7 @@
#include "jobs.h"
#include "shell.h"
#include "main.h"
+#include "mystring.h"
#include "options.h"
#include "output.h"
#include "error.h"
@@ -124,7 +125,7 @@ exvwarning2(const char *msg, va_list ap)
errs = out2;
name = arg0 ? arg0 : "sh";
- if (!commandname)
+ if (!commandname || equal(commandname, name))
fmt = "%s: %d: ";
else
fmt = "%s: %d: %s: ";
--
Olivier Duclos