bug-bash
[Top][All Lists]
Advanced

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

retrun value of buildin (( )) / GNU bash, version 4.2.24(1)-release (x86


From: Orlob Martin (EXT)
Subject: retrun value of buildin (( )) / GNU bash, version 4.2.24(1)-release (x86_64-pc-linux-gnu)
Date: Tue, 10 Jul 2012 15:32:26 +0000

Hallo,

I was using the build in (( )) function for  count up an index. I think I found 
a bug in GNU bash, version 4.2.24(1)-release (x86_64-pc-linux-gnu).

The (( )) function is working fine, but the corresponding return value does not 
match.
 Check following small example (have the focus on $?)

----------SCRIPT START-----------------
#!/bin/bash

index=-3
for a in 1 2 3 4 5 6 7  ; do
        echo "Index before: $index"
        (( index++ ))
      echo "Return value: $?"
      echo "Index after: $index"
      echo "----"
done
----------SCRIPT END------------------

OUTPUT is:


Index before: -3
Return value: 0
Index after: -2
----
Index before: -2
Return value: 0
Index after: -1
----
Index before: -1
Return value: 0
Index after: 0
----
Index before: 0
Return value: 1     <-- ?BUG? The index was counted up correctly, from 0 to 1, 
but return value of (( ))-function is "1"
Index after: 1
----
Index before: 1
Return value: 0
Index after: 2
----
Index before: 2
Return value: 0
Index after: 3
----
Index before: 3
Return value: 0
Index after: 4


Cheers,

Martin







----------------------------------------------------------
Martin Orlob - Systemintegrator

Im Auftrag der
e.solutions GmbH
GVZ Halle N West / Eingang A,
Pascalstra├če 5, 85057 Ingolstadt, Germany

Registered Office:
Pascalstr. 5, 85057 Ingolstadt, Germany

Phone +49-8458-3332-702
Fax +49-8458-3332-20130
mailto: address@hidden<mailto:address@hidden>

e.solutions GmbH
Managing Directors Uwe Reder, Dr. Riclef Schmidt-Clausen
Register Court Ingolstadt HRB 5221



reply via email to

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