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


Groups > gnu.bash.bug > #16823

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

Path csiph.com!fu-berlin.de!usenet.stanford.edu!not-for-mail
From Gabriel Winkler <gabriel.winkler@bpm.ch>
Newsgroups gnu.bash.bug
Subject Incrementing variable=0 with arithmetic expansion causes Return code = 1
Date Fri, 28 Aug 2020 08:00:30 +0000
Lines 32
Approved bug-bash@gnu.org
Message-ID <mailman.1592.1598619821.2469.bug-bash@gnu.org> (permalink)
References <GVAP278MB0118201C70D7FAF7B4DF612D98520@GVAP278MB0118.CHEP278.PROD.OUTLOOK.COM>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
X-Trace usenet.stanford.edu 1598619822 905 209.51.188.17 (28 Aug 2020 13:03:42 GMT)
X-Complaints-To action@cs.stanford.edu
To "bug-bash@gnu.org" <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
ARC-Seal i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KqB0dm5pLlXzHFWehaIJC+Uer5iev6YeIDRz5Y/QGGGCDGJRTF/eb3dU1VsDGlCvlc2QNzo/usrTd13hmNKWEVW5PtUQ/vXb8bMsN9Kq2CPhWnaLc9MlEG/ongN9axBL4V9NxzUdp3qfaYYL0HQVnIPq3qDB/wLHyrQCoc8GY7zPc/xc8Qo0sSRlzqmpelnu9akLBJlTXARvQe3hVyc/4UuemdMYMhypcgppAgoPi+CJzxKAv/YhS+rzAd/Nah2A5loeRtL9ive/dl0CI55OsQIYmxJqYbVLlRkC6YSXqLJy1edYiZSWaDnolujgKA82gFZNXyuYbXur2oO6M2XqBg==
ARC-Message-Signature i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zu1iLztpMnpfYqLDBP+mRaCmhj+kn7T7u5fBalQAHf0=; b=Q1yMFK0ZGLjeZOQw1aVSFNS491YXnHt1hrqAB7NDnAqajjdqb5Zq8VR6ypxVcMayToFZeZXalHWPOB2ij9lMlgGs4nBC/zm86J+y0i05tzHXj095tngxkTWGNyPy93sUXQxfPUkvL4Zdjpy355PsXIUdJTvfManiGNwEmlZ2v0SiPjz4eq45+pFhmpQA2hQ0n1namXKU+xkYFSSQBt7QFm5B8TdDzGbe4Vml4aHHepeZQ1aHONihHLFP3X3tjI/c5TK41wP1fx0pnucP058fp4L89Bp5IApznQHfYNPeshjWXog4bAt1ZJ+HylL8g0uEcGbpcgxyWzJbE3bv0Bxz+g==
ARC-Authentication-Results i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bpm.ch; dmarc=pass action=none header.from=bpm.ch; dkim=pass header.d=bpm.ch; arc=none
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=bpmconsultag.onmicrosoft.com; s=selector2-bpmconsultag-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zu1iLztpMnpfYqLDBP+mRaCmhj+kn7T7u5fBalQAHf0=; b=Homsub6MGmVyP8xMWC/GMLh3F2lTVNsEH9G5W9oXchUtEQBGddI4I2CLuc577JziEggwGpjK0KsSnNDJ2ctjk6mO0roefIzOK0IaWmuWsT0qfezREdTKAGm5J5yj0EZkDU1FuZ+9GIB41CuQAykXj3AsgzmSDL0dBU3uhr8ksNw=
Thread-Topic Incrementing variable=0 with arithmetic expansion causes Return code = 1
Thread-Index AQHWfRCgWJXRIs1bP0u/UaRKQTZ52Q==
Accept-Language de-CH, en-US
Content-Language de-CH
X-MS-Has-Attach
X-MS-TNEF-Correlator
authentication-results gnu.org; dkim=none (message not signed) header.d=none;gnu.org; dmarc=none action=none header.from=bpm.ch;
x-originating-ip [194.209.180.180]
x-ms-publictraffictype Email
x-ms-office365-filtering-correlation-id 17253277-30ca-4a44-78e3-08d84b286ed6
x-ms-traffictypediagnostic GV0P278MB0116:
x-microsoft-antispam-prvs <GV0P278MB011610E72B3886791C667F9498520@GV0P278MB0116.CHEP278.PROD.OUTLOOK.COM>
x-ms-oob-tlc-oobclassifiers OLM:8273;
x-ms-exchange-senderadcheck 1
x-microsoft-antispam BCL:0;
x-microsoft-antispam-message-info tW++G6aQ3Rf8OXai0mNmPyCrOtrq8FLT+Rspm5Q7m7edCJ+Mzv5REfB2tgsWBLhGKT0uvzw6HgaDrU12tlwEpALezdfjnB26KZL1LVZTSp+GklgFYjwlrFTaIAJwiKG03RCGKix2yxwm3sOJppvcG6mPHU492KsB253Cl7olImNO6oL9HW1tDHnAY6wez/o/iySBEG+xhYwClRGFpgU/hP1nYJaMXfFfXrodoXIEu0klA4dZhx8+MSnp4jMN+/B9MdCCT1wDoRZeLVuiCkt5wuCVuq10AXF3hbJVJcR/htUPKDu65NNHAtc5Ip1zdVwFih/YSruGaXCYPMe/llyDXlxcgBLFEzSt61nDTl06lDyUMOy2HY/oX1yH2pTc/LSlm2wGNlP4VcZMQA77Y9TTbQ==
x-forefront-antispam-report CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GVAP278MB0118.CHEP278.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(346002)(366004)(136003)(376002)(39830400003)(396003)(71200400001)(76116006)(19627405001)(2906002)(66946007)(66476007)(86362001)(64756008)(66446008)(166002)(66556008)(83080400001)(6506007)(186003)(26005)(83380400001)(7696005)(44832011)(6916009)(316002)(52536014)(33656002)(55016002)(9686003)(5660300002)(478600001)(8936002)(8676002); DIR:OUT; SFP:1102;
x-ms-exchange-antispam-messagedata lc1zzZU4NYNlPEbQXKjd0X/JlwfN11FafSlq7uFE73eo6O2k53KdX5qbh0/tK9HScqjvFVLxj+gGQNj4FMM3u6em2hkq8q8DiCZTTLRcryhUrTcptmjuUd6YPzejLYHc6AV7L21GSRa6ThWBbcBJCRokKSVx1zPWNRC5dE2bi406OpSBGcsZamqbcXfDfhDXVRky0oOSjFD3Cez1ZTmpd4peZ9JCCppyDeKyomXbuBX033D692LiYLNQYPiQgYLE2vUWAuysCAI5euTaBB+4FYtnksO40pL9uG1DpHARe2cwwFFUvi1CqoxE1s8eRZcW4c/WnqWpzlesnV9Z2A7KResw+nV1IMgZMr+vveYk2Y8y34KNNFvfeSUUNZwA60LArlDUl2+uIMglp6soEa5124pmnqSeHomhn3zax6bhyq05ugGkB02lriQA19XS8ASatEFYqOfJoG8xGjQ+rXBwjZysqQL1a0ATXoyHg8PIVLoDU4iM2hhvwy0LSAFVvd2i9ZxIioHgWddo6aF1a/ssw3pddCuGXRkxKzVuVrI9LacWXuODwvkVqI5N4zKqn/x0oQVXaiBLaQ+jkgKRt4SOZnzU8oYs4NFR9lPbZE5SZJzEhUQzW6SMdKrWtup0Sw3Uh+9bUnmAbgMUujIwrspyEA==
x-ms-exchange-transport-forked True
X-OriginatorOrg bpm.ch
X-MS-Exchange-CrossTenant-AuthAs Internal
X-MS-Exchange-CrossTenant-AuthSource GVAP278MB0118.CHEP278.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-Network-Message-Id 17253277-30ca-4a44-78e3-08d84b286ed6
X-MS-Exchange-CrossTenant-originalarrivaltime 28 Aug 2020 08:00:30.0581 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader Hosted
X-MS-Exchange-CrossTenant-id a36597c8-d54f-4ee4-a0ae-b88471eba9b1
X-MS-Exchange-CrossTenant-mailboxtype HOSTED
X-MS-Exchange-CrossTenant-userprincipalname yFSj7cYewEeomNa+n7mRpRfT9B8XE27BVz4MwqgkrSV6bMzeWPzNvxCvcD+himXewGBVZdHaKkXJG9FjuSmkug==
X-MS-Exchange-Transport-CrossTenantHeadersStamped GV0P278MB0116
Received-SPF pass client-ip=40.107.24.122; envelope-from=gabriel.winkler@bpm.ch; helo=CHE01-ZR0-obe.outbound.protection.outlook.com
X-detected-operating-system by eggs.gnu.org: First seen = 2020/08/28 04:15:37
X-ACL-Warn Detected OS = Windows NT kernel [generic] [fuzzy]
X-Spam_score_int -25
X-Spam_score -2.6
X-Spam_bar --
X-Spam_report (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action no action
X-Mailman-Approved-At Fri, 28 Aug 2020 09:03:40 -0400
X-Content-Filtered-By Mailman/MimeDel 2.1.23
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 <GVAP278MB0118201C70D7FAF7B4DF612D98520@GVAP278MB0118.CHEP278.PROD.OUTLOOK.COM>
Xref csiph.com gnu.bash.bug:16823

Show key headers only | View raw


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/>

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


Thread

Incrementing variable=0 with arithmetic expansion causes Return code = 1 Gabriel Winkler <gabriel.winkler@bpm.ch> - 2020-08-28 08:00 +0000

csiph-web