From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/3] commands/test: Bail out on incomplete command line options
Date: Mon, 3 Feb 2020 08:57:07 +0100 [thread overview]
Message-ID: <20200203075707.wc2q5f4isveehjuk@pengutronix.de> (raw)
In-Reply-To: <20200128130801.24890-2-u.kleine-koenig@pengutronix.de>
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@pengutronix.de>
> ---
> 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@lists.infradead.org
> 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-02-03 7:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-28 13:07 [PATCH 0/3] commands/test: some improvements Uwe Kleine-König
2020-01-28 13:07 ` [PATCH 1/3] commands/test: Bail out on incomplete command line options Uwe Kleine-König
2020-02-03 7:57 ` Sascha Hauer [this message]
2020-02-03 8:50 ` Uwe Kleine-König
2020-01-28 13:08 ` [PATCH 2/3] commands/test: Improve option parsing to handle "]" less special Uwe Kleine-König
2020-01-28 13:08 ` [PATCH 3/3] commands/test: Implement -b and -c to test for character and block devices Uwe Kleine-König
2020-02-04 7:40 ` [PATCH 0/3] commands/test: some improvements Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200203075707.wc2q5f4isveehjuk@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox