In article <ridsnb$r6m$
1...@news-1.m-online.net>,
Janis Papanagnou <
janis_pa...@hotmail.com> wrote:
...
>> [...] Note that it would really be nice to have a builtin way to do decimal
>> math in bash - sounds like a good project to write an extension library to
>> do that.
>I know how difficult it is to switch tools that one is used to, specifically
>if it is the shell (the one that is prevalent the default shell on Linux),
>but sometimes it's easier to just replace #!/bin/bash by #!/bin/ksh and
>you have (besides many other features) the math not restricted to integers.
Yeah, well, I think you've answered your own question. At this point, I'm
pretty invested in bash. Among other things, the fact is that it isn't
just a single machine - I'd have to make the change everywhere and also
whenever a new machine comes online, make it there. It's just too much
trouble. In fact:
1) When I tried out ksh (a few decades ago), I was not impressed. No
doubt it has improved since then, but for whatever it is worth, it
wouldn't be my first choice.
2) I'm a big fan of tcsh. If I were going to make a shell change
(i.e., commit to swimming upstream for the rest of my life), I'd go
with tcsh. In fact, when I first started using Linux, I did
install and use tcsh on each new machine, but after a while, that
just got old.
This is probably a large part of why people often say that you shouldn't
program anything non-trivial in shell - because of the lock-in effect.
Because shells seem to be pretty ephemeral (as compared to lower-level
languages).
>> Note that "bc" almost works - "bc" is my usual goto for doing
>> this (decimal math in shell), but "bc" has its own set of issues. I
>> usually end up going back to AWK.
>
>Curious; what bc issues do you mean?
Well, first of all, I'm not looking for help or workarounds or "You're not
doing it right" type responses. This is just in the spirit of discussion.
And, you know, I'm not even sure I can remember all the things I've run
into. I would probably best describe it as "incomplete" and "not well
documented". It's one of those things where you go with it for a while,
and then you hit something. There's always that feeling that you're going
to hit a wall at any moment. And the man page, while full and complete I'm
sure, is not a thing of beauty.
Here are two examples off the top of my head (I'm sure there are more, but
they don't come to mind at the moment):
1) You can't write a leading plus sign. You can't write +8 as a number.
2) The collection of functions is anemic. F.e., I couldn't find an "int()"
function.
Like I said, it's not really that's there's bugs; it is just "incomplete".
Now, totally changing the subject (but not really), one thing that annoys
me about bash's $(( )) functionality is what I call "the leading zero" bug.
That is, that if you write 08 as a number, it blows up. Yes, I know why
this is not technically a bug, but it is annoying. Neither bc nor awk
suffer from this. But, surprisingly, Perl *does*.
--
BigBusiness types (aka, Republicans/Conservatives/Independents/Liberatarians/whatevers)
don't hate big government. They *love* big government as a means for them to get
rich, sucking off the public teat. What they don't like is *democracy* - you know,
like people actually having the right to vote and stuff like that.