Re: [PATCH] options: Do not set commandname in procargs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Your patch seems even better!

Thanks.
-- 
  Olivier Duclos

On Mon, Feb 25, 2019, at 05:49, Herbert Xu wrote:
> 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@xxxxxxxxxxxx>
> Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> 
> 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;
> -- 
> Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
>



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux