bug-bash
[Top][All Lists]
Advanced

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

cond?true:false and division by 0


From: dnade.ext
Subject: cond?true:false and division by 0
Date: Mon, 1 Aug 2011 10:41:18 +0200

        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) ?

        D

--
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



********************************************************************************
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]