Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: "" 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: References: <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: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddvjedgvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgogfhmphhthietlhhirghsucdlvddtmdenucfjug hrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpedffdcuoehkfhhm sehplhhushhhkhgrvhgrrdhnvghtqeenucggtffrrghtthgvrhhnpeekueekudekvdekgf dvffdvgeegveehgfffhfeuuddtleehtdehvdekkeduudevkeenucfkphepudelfedrudef kedrvddukedrudeltdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehkfhhmsehplhhushhhkhgrvhgrrdhnvght X-ME-Proxy: User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.2.0 In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <8c456f29-8e0d-e0bc-4645-c7cc5b6c6471@plushkava.net> X-Mailman-Original-References: Xref: csiph.com gnu.bash.bug:16825 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