🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #4146

ksh->bash and floating point arithmetic

#4146
From: Tristan Miller
Date: Mon, 08 Dec 2003 14:25
30 lines
2283 bytes
Greetings.

I have a set of KornShell (ksh93) scripts, some fairly large, which I
wish to convert to GNU bash scripts for the following reasons:

a) the KornShell licence is too restrictive;
b) there is too much inconsistency in the version of ksh provided by
various Unix vendors;
c) in my experience, bash tends to be easier to compile and install than
ksh93; and
d) if I'm going to convert ksh93 code into anything, converting it into
bash will probably require the least number of changes.

The reason the scripts were written in ksh93 to begin with is its
support for floating-point arithmetic.

Up until now I have been replacing the ksh93-specific arithmetic
operators with calls to bash functions which invoke bc.  This seems to
work as expected, but apart from rewriting everything in, say, Perl, is
there a better or more efficient way of getting floating-point
arithmetic?

Regards,
Tristan

-- 
   _
  _V.-o  Tristan Miller [en,(fr,de,ia)]  ><  Space is limited
 / |`-'  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  <>  In a haiku, so it's hard
(7_\\    http://www.nothingisreal.com/   ><  To finish what you
Technical Details
Message-ID: <2726696.9viUAlbAWN@ID-187157.news.dfncis.de>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.tiscali.de!news.belwue.de!news.uni-kl.de!port-3106.kl.dfki.de!news

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109f73,c9a9cf8582f4663a,start
X-Google-Attributes: gid109f73,public
X-Google-Thread: 1012a6,c9a9cf8582f4663a,start
X-Google-Attributes: gid1012a6,public
X-Google-ArrivalTime: 2003-12-08 06:45:08 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.tiscali.de!news.belwue.de!news.uni-kl.de!port-3106.kl.dfki.de!news
From: Tristan Miller <psychonaut@nothingisreal.com>
Newsgroups: comp.unix.shell,gnu.utils.help
Subject: ksh->bash and floating point arithmetic
Date: Mon, 08 Dec 2003 15:25:55 +0100
Organization: http://www.nothingisreal.com/
Lines: 30
Message-ID: <2726696.9viUAlbAWN@ID-187157.news.dfncis.de>
NNTP-Posting-Host: dfki-2001.dfki.uni-kl.de
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
X-Trace: news.uni-kl.de 1070894522 19545 131.246.241.2 (8 Dec 2003 14:42:02 GMT)
X-Complaints-To: usenet@news.uni-kl.de
NNTP-Posting-Date: Mon, 8 Dec 2003 14:42:02 +0000 (UTC)
User-Agent: KNode/0.7.2
X-Accept-Language: en-ca, en-us, en-gb, en, fr, de, ia