Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16826

Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Chris Elvidge <celvidge001@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1
Date Fri, 28 Aug 2020 14:42:05 +0100
Lines 67
Approved bug-bash@gnu.org
Message-ID <mailman.1600.1598622141.2469.bug-bash@gnu.org> (permalink)
References <GVAP278MB0118201C70D7FAF7B4DF612D98520@GVAP278MB0118.CHEP278.PROD.OUTLOOK.COM> <rib1je$12lc$1@ciao.gmane.io>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace usenet.stanford.edu 1598622141 2355 209.51.188.17 (28 Aug 2020 13:42:21 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
X-Injected-Via-Gmane http://gmane.org/
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 Lightning/5.4
In-Reply-To <GVAP278MB0118201C70D7FAF7B4DF612D98520@GVAP278MB0118.CHEP278.PROD.OUTLOOK.COM>
Content-Language en-GB
Received-SPF pass client-ip=116.202.254.214; envelope-from=gnu-bug-bash-3@m.gmane-mx.org; helo=ciao.gmane.io
X-detected-operating-system by eggs.gnu.org: First seen = 2020/08/28 09:42:12
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int 20
X-Spam_score 2.0
X-Spam_bar ++
X-Spam_report (2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.809, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <rib1je$12lc$1@ciao.gmane.io>
X-Mailman-Original-References <GVAP278MB0118201C70D7FAF7B4DF612D98520@GVAP278MB0118.CHEP278.PROD.OUTLOOK.COM>
Xref csiph.com gnu.bash.bug:16826

Show key headers only | View raw


On 28/08/2020 09:00 am, Gabriel Winkler wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc -I/home/abuild/rpmbuild/BUILD/bash-4.4 -L/home/abuild/rpmbuild/BUILD/bash-4.4/../readline-7.0
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-suse-linux-gnu' -DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g  -D_GNU_SOURCE -DRECYCLES_PIDS -Wall -g -Wuninitialized -Wextra -Wno-switch-enum -Wno-unused-variable -Wno-unused-parameter -Wno-parentheses -ftree-loop-linear -pipe -DBNC382214=0 -DIMPORT_FUNCTIONS_DEF=0 -fprofile-use -fprofile-correction
> uname output: Linux sophie 4.12.14-150.32-default #1 SMP Thu Aug 1 08:42:52 UTC 2019 (a2a3983) x86_64 x86_64 x86_64 GNU/Linux
> Machine Type: x86_64-suse-linux-gnu
> 
> Bash Version: 4.4
> Patch Level: 23
> Release Status: release
> 
> Description:
> If I have a variable with the value 0 assigned to it incrementing it causes the return code to be 1, even though the variable has been incremented successfully. This only happens if the value of the variable is 0. With positive and negative values this bug is no present.
> 
> Repeat-By:
> # Works fine
> test=1
> ((test++))
> echo $?
> 0
> echo $test
> 2
> 
> # Causes error
> test=0
> ((test++))
> echo $?
> 1
> echo $test
> 1
> 
> 
> ​Best Regards
> 
> Gabriel Winkler
> 
> _________________________
> 
> bpm consult ag
> beeline solutions
> Gabriel Winkler
> DevOps Engineer
> Industriestrasse Ost 10
> CH-4614 Hägendorf
> 
> Telefon +41 61 417 10 68
> Web     www.bpm.ch<http://www.bpm.ch/>
> 

 From man bash:

((expression))
The expression is evaluated according to the rules described
below under ARITHMETIC EVALUATION.  If the value of the
expression is non-zero, the return status is 0; otherwise the
return status is 1.  This is exactly equivalent to
let "expression".



-- 
Chris Elvidge
England

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1 Chris Elvidge <celvidge001@gmail.com> - 2020-08-28 14:42 +0100

csiph-web