diff mbox series

options: Do not set commandname in procargs

Message ID 20190225044920.k2klmeddvn2ybc3b@gondor.apana.org.au (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series options: Do not set commandname in procargs | expand

Commit Message

Herbert Xu Feb. 25, 2019, 4:49 a.m. UTC
On Mon, Jan 28, 2019 at 03:58:24PM +0000, Olivier Duclos wrote:
> 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.

Thanks for the report!

How about this patch?

---8<---
We set commandname in procargs when we don't have to.  This results
in a duplicated output of arg0 when an error occurs.

Reported-by: Olivier Duclos <odc@fastmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

Olivier Duclos Feb. 25, 2019, 8:56 a.m. UTC | #1
Your patch seems even better!

Thanks.
diff mbox series

Patch

diff --git a/src/options.c b/src/options.c
index 6f381e6..a46c23b 100644
--- a/src/options.c
+++ b/src/options.c
@@ -159,7 +159,6 @@  procargs(int argc, char **argv)
 		setinputfile(*xargv, 0);
 setarg0:
 		arg0 = *xargv++;
-		commandname = arg0;
 	}
 
 	shellparam.p = xargv;