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


Groups > gnu.bash.bug > #16825

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 "" <kfm@plushkava.net>
Newsgroups gnu.bash.bug
Subject Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1
Date Fri, 28 Aug 2020 14:09:05 +0100
Lines 39
Approved bug-bash@gnu.org
Message-ID <mailman.1595.1598620153.2469.bug-bash@gnu.org> (permalink)
References <GVAP278MB0118201C70D7FAF7B4DF612D98520@GVAP278MB0118.CHEP278.PROD.OUTLOOK.COM> <8c456f29-8e0d-e0bc-4645-c7cc5b6c6471@plushkava.net>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1598620154 1118 209.51.188.17 (28 Aug 2020 13:09:14 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=plushkava.net; h=subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=Z XZL1sTppafFEYeirKFpcU9yAqe1tPV4ePEzgKAUBlc=; b=T+3SuHzE4v2NiurDq x3481JBds1JACilerRhZc+A6lCS0//1uwWYhpA7VKK+JZ5s8shvZcvRtVP81XlOt fzK8PRL+OsX0XlJQZNAV24FVVKiYFyy8ImxaRqothGjVaPGuuzXwIVnwN7k+6o5y FyxDckaLCPewsvFdonEnE4lDa5l7fEYjmXKyGxcjjyaSEXpNhn3E6xL0hQ2s16fN Jpw0dEbrGJv2a9YXuomKgC70Umh+mzE67D5YOjZtFA98l7so8dQCaw/A9hTZe2qO /ZVXJkWXnzehkA5AnfXFHQXW4TAszg1J1WNT1+1oB1Y3W0oKOH9rQx8WUxRZyS1A dE1dQ==
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=ZXZL1sTppafFEYeirKFpcU9yAqe1tPV4ePEzgKAUB lc=; b=g0I0/VBW0o3SIptWDgwNi3HaX8iQTZk0CkuZbmTHUnpYqBEhC+LOxs5Lf yTQx2LHYYn7i4wyCR4Y4fX8IaWwecPxHIov3BzHtyj+v8tUSgogOXUyvfVBdz8V5 qD7/9afTez7mwZsInNDaz3FyceO/tjKGR3l6Lwd6Ix9o4RNCD8srHrVx5YyoIB31 01vaSsg8GssfZb5igv2/iyLRgumgKA1mo1xT5fVP/Bzimg9c91eHrmFORcEitg2B sxtzFdB1uchfdfKM9gDDv4efZyxyHSi0GtSWOJUT6amuLJfVcIbvPeB3Cagb2pt+ H9BzqKMJRGe0vqKegfw5iybrYO1dw==
X-ME-Sender <xms:8wFJX1sZm1M5IJDJldMGEH45brsh_7mGa7nMM4azU9BGxwf8EARePA>
X-ME-Proxy-Cause gggruggvucftvghtrhhoucdtuddrgeduiedruddvjedgvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgogfhmphhthietlhhirghsucdlvddtmdenucfjug hrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpedffdcuoehkfhhm sehplhhushhhkhgrvhgrrdhnvghtqeenucggtffrrghtthgvrhhnpeekueekudekvdekgf dvffdvgeegveehgfffhfeuuddtleehtdehvdekkeduudevkeenucfkphepudelfedrudef kedrvddukedrudeltdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehkfhhmsehplhhushhhkhgrvhgrrdhnvght
X-ME-Proxy <xmx:8wFJX-epq4PMDGPtdp5ravSLgDLoUQzznE0T4ohYCiSEJ8vCVWxIOQ> <xmx:8wFJX4w5ETWl6juwu-gqdE1CoV7U1ndHrLJgo3rrKjAINSwEQGcuyg> <xmx:8wFJX8O0_MunkrkiRYysrz4Lh9kxjilZuCH52SbhlogkZ8JN039wDA> <xmx:8wFJX7cIjRQ2kwn4uTiyqI3Ufc0BMg9rjmZlKA2o4V9nvN6hT4wmsw>
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.2.0
In-Reply-To <GVAP278MB0118201C70D7FAF7B4DF612D98520@GVAP278MB0118.CHEP278.PROD.OUTLOOK.COM>
Content-Language en-US
Received-SPF pass client-ip=66.111.4.29; envelope-from=kfm@plushkava.net; helo=out5-smtp.messagingengine.com
X-detected-operating-system by eggs.gnu.org: First seen = 2020/08/28 09:09:07
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int -28
X-Spam_score -2.9
X-Spam_bar --
X-Spam_report (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_BLANK_NAME=0.723, NICE_REPLY_A=-0.809, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 <8c456f29-8e0d-e0bc-4645-c7cc5b6c6471@plushkava.net>
X-Mailman-Original-References <GVAP278MB0118201C70D7FAF7B4DF612D98520@GVAP278MB0118.CHEP278.PROD.OUTLOOK.COM>
Xref csiph.com gnu.bash.bug:16825

Show key headers only | View raw


On 28/08/2020 09:00, 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

This isn't a bug. You should write ((++test)) if you want the 
post-incremented value to be evaluated.

-- 
Kerin Millar

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


Thread

Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1 "" <kfm@plushkava.net> - 2020-08-28 14:09 +0100

csiph-web