[Top][All Lists]

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

RE: cond?true:false and division by 0

From: dnade.ext
Subject: RE: cond?true:false and division by 0
Date: Thu, 11 Aug 2011 10:22:49 +0200


Sorry for the delay.

I've applied your expr-noeval.patch file to the bash-4.2.10-4.fc15 package 
provided by fedora.
The problem seems solved. :)

Thanks !


Damien Nadé <address@hidden>
Astek Sud-Est pour France Télécom - FT/OF/OFA/DMGP/PORTAIL/DOP/DEV/EAQS
Sophia Antipolis - France / Tel : 04 97 12 86 20

> -----Message d'origine-----
> De : Chet Ramey [mailto:address@hidden
> Envoyé : mercredi 3 août 2011 03:14
> Cc : address@hidden; address@hidden
> Objet : Re: cond?true:false and division by 0
> On 8/1/11 8:47 PM, Chet Ramey wrote:
> > On 8/1/11 4:41 AM, address@hidden wrote:
> >>    Hello
> >>
> >> I wanted to check a variable before attempting to divide something by
> it, so I wrote :
> >>
> >> echo $(( foo==0?0:something/foo ))
> >>
> >> And bash 2, 3 and up to 4.2.10 version sent me a "division by 0" error.
> >>
> >> So, I've tested a static version of the statement :
> >>
> >> $ echo $(( 0==0?0:1/0 ))
> >> -bash: 0==0?0:1/0 : division by 0 (error token is " ")
> >>
> >> It looks like the "division by 0" happens whatever the condition
> result.
> >> Shouldn't it happen only if condition result make the computing go that
> far (like, FWIW, in zsh) ?
> >
> > Hmm...this looks like a precedence problem.  I'll take a look.
> It's not actually a precedence problem.  The check for division by 0
> shouldn't take place when evaluation is suppressed.  (The bash
> arithmetic evaluator, like most others of its type, is parse-and-
> evaluate-on-the-fly, so all operands are evaluated.
> Please try the attached patch and see if it works for you.

IMPORTANT.Les informations contenues dans ce message electronique y compris les 
fichiers attaches sont strictement confidentielles
et peuvent etre protegees par la loi.
Ce message electronique est destine exclusivement au(x) destinataire(s) 
mentionne(s) ci-dessus.
Si vous avez recu ce message par erreur ou s il ne vous est pas destine, 
veuillez immediatement le signaler  a l expediteur et effacer ce message 
et tous les fichiers eventuellement attaches.
Toute lecture, exploitation ou transmission des informations contenues dans ce 
message est interdite.
Tout message electronique est susceptible d alteration.
A ce titre, le Groupe France Telecom decline toute responsabilite notamment s 
il a ete altere, deforme ou falsifie.
De meme, il appartient au destinataire de s assurer de l absence de tout virus.

IMPORTANT.This e-mail message and any attachments are strictly confidential and 
may be protected by law. This message is
intended only for the named recipient(s) above.
If you have received this message in error, or are not the named recipient(s), 
please immediately notify the sender and delete this e-mail message.
Any unauthorized view, usage or disclosure ofthis message is prohibited.
Since e-mail messages may not be reliable, France Telecom Group shall not be 
liable for any message if modified, changed or falsified.
Additionally the recipient should ensure they are actually virus free.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]