Marc Weber wrote:
> Chet:
>> To do otherwise would have made expr much less useful. Idioms such as
>>
>> var=10
>> while var=`expr $var - 1`
>> do
>> echo $var
>> done
>
> Mmh I'd use the C like for loop for this which is supported by bash as well.
>
A relatively recent addition to the
On Tue, Jun 30, 2009 at 09:58:45PM +0200, Marc Weber wrote:
> How is this done?
>
> CHK0="test $? == 0"
> my_important_task; $CHK0 || exit 1
You'd need single quotes instead of double there. (And == is illegal in
Bourne/POSIX shell test commands; only bash tolerates it.) You could
also use a fu
Greg Wooledge:
> 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.
How is this done?
CHK0="test $? == 0"
my_important_task; $CHK0 || exit 1
Chet:
> To do otherwise would have m
Chet Ramey wrote:
> It depends on what you mean by `fail'.
> ...
> To do otherwise would have made expr much less useful. Idioms such as
Also I must mention grep too. The exit status of grep isn't just
whether it exits without an error but instead returns an indication of
whether the pattern mat
> > echo `expr $var - 1`
> shrug. I didn't knew that either.
> 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.
It depends on what you mean by `fail'. expr certainly returns a non-zero
result for th
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 diff
On Thu, Jun 25, 2009 at 07:33:18PM -0400, Chet Ramey wrote:
> Marc Weber wrote:
>
> > This is my point: I'd like to tell bash: Whenever running an executable
> > assume that if it returns a non zero exit status that's a unforeseen
> > exception. And in this case don't continue as usual but abort a
Marc Weber wrote:
> This is my point: I'd like to tell bash: Whenever running an executable
> assume that if it returns a non zero exit status that's a unforeseen
> exception. And in this case don't continue as usual but abort and return
> non zero exit status yourself. set -e comes close.
You're
On Tue, Jun 23, 2009 at 09:00:10AM -0400, Chet Ramey wrote:
> Marc Weber wrote:
> > Hi,
> >
> > I stumbled about another bash problem today:
> >
> > for item in $(false);
> > echo $item
> > done || { echo for failed; }
> >
> > doesn't fail. I think it's bad that there is no
> > set -e
> >
Marc Weber wrote:
> Hi,
>
> I stumbled about another bash problem today:
>
> for item in $(false);
> echo $item
> done || { echo for failed; }
>
> doesn't fail. I think it's bad that there is no
> set -e
>
> like switch which really catches all failures of this kind.
This isn't really abo
10 matches
Mail list logo