mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Denis Osterland-Heim <denis.osterland@diehl.com>
To: "a.fatoum@pengutronix.de" <a.fatoum@pengutronix.de>,
	"barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: Not successful if statements returning error code
Date: Thu, 29 Jul 2021 09:48:13 +0000	[thread overview]
Message-ID: <d5905da7db8e8f867e0a9e2c0a3c58e48eea7a8f.camel@diehl.com> (raw)
In-Reply-To: <1e471a43-3b6c-f632-1359-6f44a06f8c54@pengutronix.de>

Hi,

Am Donnerstag, den 29.07.2021, 11:22 +0200 schrieb Ahmad Fatoum:
> On 28.07.21 11:38, Denis Osterland-Heim wrote:
> > Hi,
> >
> > Am Mittwoch, den 28.07.2021, 10:56 +0200 schrieb Ahmad Fatoum:
> >
> > > I talked with Sascha once before (off-list) about a similar issue. Missing error handling
> > > results in
> > >
> > >   [ x1 -eq x2 ] && echo yes || echo no
> > >
> > > printing yes.
> > >
> > > We agreed that it's ok to break scripts relying on clear hush bugs like this.
> > >
> > > I'd thus recommend you to send a patch to fix hush instead of working around it.
> >
> > shellcheck says:
> >
> > SC2015: Note that A && B || C is not if-then-else. C may run when A is true.
> >
> > So I would think that B is maybe allowed to run before A, too.
> > But, I do not know if Hush specifies execution order here.
>
> An option-less barebox echo can't fail, so it should never
> print both yes and no, but thanks for the reference. I'll keep
> an eye on it in future shell code.
>
> This wasn't what I meant to show though, I meant that x1 and x2
> are both non-integers and -eq which compares integers returns
> true when comparing them unlike what a POSIX shell does.
Oh. Now I got your point ;-)

https://git.pengutronix.de/cgit/barebox/tree/commands/test.c#n182
error handling is missing here.
It is very likely that simple_strtol() returns the same value in case of error,
which results in a successfully compare.

Regards, Denis

>
> Cheers,
> Ahmad
>
>
> >
> > Regards, Denis
> >
> > >
> > > Cheers,
> > > Ahmad
> > >
> > > >
> > > > Thank you for your answer.
> > > >
> > > > Best regards,
> > > > Andrej
> > > >
> > > > _______________________________________________
> > > > barebox mailing list
> > > > barebox@lists.infradead.org
> > > > http://lists.infradead.org/mailman/listinfo/barebox
> > > >
> > >
> > >
> >
> > Diehl Connectivity Solutions GmbH
> > Geschäftsführung: Horst Leonberger
> > Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
> > Nürnberg: HRB 32315
> >
> > ________________________________
> >
> > Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
> > Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
> > Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.
> >
> > - Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie unter:
> >
> > https://www.diehl.com/group/de/transparenz-und-informationspflichten/
> >
> > The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
> > mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited.
> >
> > - For general information on data protection and your respective rights please visit:
> >
> > https://www.diehl.com/group/en/transparency-and-information-obligations/
> >
> >
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
> >
>
>
Diehl Connectivity Solutions GmbH
Geschäftsführung: Horst Leonberger
Sitz der Gesellschaft: Nürnberg - Registergericht: Amtsgericht
Nürnberg: HRB 32315

________________________________

Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht.
Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.

- Informationen zum Datenschutz, insbesondere zu Ihren Rechten, erhalten Sie unter:

https://www.diehl.com/group/de/transparenz-und-informationspflichten/

The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by
mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited.

- For general information on data protection and your respective rights please visit:

https://www.diehl.com/group/en/transparency-and-information-obligations/


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

  reply	other threads:[~2021-07-29  9:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-23 10:18 Andrej Picej
2021-07-27  5:20 ` Andrej Picej
2021-07-28  8:56 ` Ahmad Fatoum
2021-07-28  9:38   ` Denis Osterland-Heim
2021-07-29  9:22     ` Ahmad Fatoum
2021-07-29  9:48       ` Denis Osterland-Heim [this message]
2021-08-09 10:54         ` Ahmad Fatoum

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=d5905da7db8e8f867e0a9e2c0a3c58e48eea7a8f.camel@diehl.com \
    --to=denis.osterland@diehl.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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