Re: [PATCH 1/3] commands/test: Bail out on incomplete command line options

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

 



On Tue, Jan 28, 2020 at 02:07:59PM +0100, Uwe Kleine-König wrote:
> This makes test emit an error (and fail) on e.g.
> 
> 	test -f

test -f in bash returns 0 as well and also doesn't emit an error.

> 
> and also on unimplemented options like
> 
> 	test -c /dev/null

test -H /foo/bar in bash says "bash: test: -H: unary operator expected".

I am not sure how relevant this is, but the behaviour you introduce is
not consistent to bash.

Sascha


> 
> .
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
> ---
>  commands/test.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/commands/test.c b/commands/test.c
> index c4f493860f14..ab108fc845d5 100644
> --- a/commands/test.c
> +++ b/commands/test.c
> @@ -208,6 +208,11 @@ static int do_test(int argc, char *argv[])
>  			}
>  		}
>  
> +		if (left < adv) {
> +			printf("test: failed to parse arguments\n");
> +			return 1;
> +		}
> +
>  		if (last_cmp == 0)
>  			expr = last_expr || expr;
>  		else if (last_cmp == 1)
> -- 
> 2.24.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@xxxxxxxxxxxxxxxxxxx
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux