Hi,

On 23/04/17 14:42, David via luv-main wrote:
> If you insist on using 'set -e', you could do this to disable
> exitstatus checking on arithmetic contexts:
> 
> set -eu
> i=0
> for a in a b c
> do
>    echo "${a}"
>    ((i++)) || true
> done

Yes, that would be the cleanest way to solve this.  Thanks.

I solved it a different way though:

for ((i=0;i<${#arrayx[@]};i++))
do
   ....
done

The reason why I need the index is because there is a different array
that I rely upon that has corresponding (1 to 1) values relative to the
first array.


I concede that there are multiple "correct" answers, but can only agree
to disagree on ones that I believe are at odds with being sane.


My view is that:
  "I am asking bash to increment a number, ANY number"

The number is incremented successfully (in every case), but the value of
$? (return status) is different depending on the value of the number
given for bash to increment.  That's where I see it as wrong.

The only situation where I think it should return a failure status is
when incrementing the number by 1 causes the result to be a negative
number due to wrap around of the value in the variable such as this one:

   https://en.wikipedia.org/wiki/9223372036854775807


As I understand it, bash should only ever give a return status that
indicates failure if it was not able to increment the given variable;
there is no valid reason to do otherwise.

Cheers
A.

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
luv-main mailing list
[email protected]
https://lists.luv.asn.au/cgi-bin/mailman/listinfo/luv-main

Reply via email to