bug-bash
[Top][All Lists]
Advanced

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

Re: feature request: more complete set -e


From: Greg Wooledge
Subject: Re: feature request: more complete set -e
Date: Mon, 29 Jun 2009 09:15:00 -0400
User-agent: Mutt/1.4.2.2i

On Mon, Jun 29, 2009 at 12:45:29AM +0200, Marc Weber wrote:
> > echo `expr $var - 1`
> I think that this is bad. expr should do some calculation. If the
> calculation fails (eg devision by zero) the return value should be non
> zero.

You'd think so, but alas, the people who made expr(1) had a different
concept of how they wanted it to work.

> But yeah. You've just given me another example why you need deep active
> knowledge to write good scripts
> 
> Maybe I should rather just use perl, python, ruby or php instead of
> continuing this thread then

While I definitely support using the correct language for the job --
and often, the correct language for a specific job is *not* going to be
bash -- you're making things more complex than they really need to be.
You're trying to find some magic imp that will automatically do things
for you.  If you simply handle errors yourself by checking the return
code from commands that actually matter, you won't have to worry about
all these nasty little surprises.




reply via email to

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