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


Groups > gnu.bash.bug > #14303

Re: Number with sign is read as octal despite a leading 10#

Path csiph.com!goblin3!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Clint Hepner <clint.hepner@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Number with sign is read as octal despite a leading 10#
Date Mon, 9 Jul 2018 21:37:49 -0400
Lines 34
Approved bug-bash@gnu.org
Message-ID <mailman.3346.1531186726.1292.bug-bash@gnu.org> (permalink)
References <CA+n9pTy7vSPUA0j-bDF9_eWF0XysePRDAFckgvvHX8haSWv7KQ@mail.gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1531186727 6752 208.118.235.17 (10 Jul 2018 01:38:47 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org, bash@packages.debian.org, Isaac Marcos <isaacmarcos100010@gmail.com>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version; bh=Ab5edXzgLK07VK9v2VwC0GlcQDb1OEf3Fpq1FdKmQiw=; b=T+CkSEejibtvQpRX8Pgk1jbbloPW+vy4ct0LBIAypz/OZ84E6c21NvF+FfiQyOaIt0 zrF2NdYE/mCXmbCODds4CaSqzd4qaTywZiLFHuciJzlWnRd9/yGLSsrqD92EU3pEryJX +pVxesimyY2fxe1RM0gGrP0qWVgENkFZZIbjrzB3QQhRDdVNqr8dg/SGBID1zr0fvGgX BHANZlt3/uC65orSaAunh7V6JHNvKgqRZoUbjI8nNhZGcx8Xx7jsTTEquAwXSs/0PLN8 gMcIaXDMtbPjIIqWKWFJkpJr2bynx3DHwn2G6/XnlZigB9Jdx3/6J0ynKzdzpEl/ASos MQbQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:message-id:in-reply-to:references :subject:mime-version; bh=Ab5edXzgLK07VK9v2VwC0GlcQDb1OEf3Fpq1FdKmQiw=; b=TbaWJgT8yAobE6718g6cZkjqFC7LAg7WuybWuTJc65XdUbvKCxtLntZvZrtgYMyYuq f6UUVQKg9piAagLOI9XjNNiIdZohy28eVCAmSBpyEitIJoGh9D39+eC1vFwspmcgYTzC kczpgHHGIlS2MSVrFA1qPQKHGWaT0mgKTya4Q6d70v+/vb730u17CLlKiaL3ckSxYLGf mqUIXNGqvCESi133zK1r8TJizPxoZnokalVI6Lky0ekGVe60Vqa2N4iq+BbaBhLbCxfS LTH+a9LmeAxkTNA6uKoP8YhK3xwte2ChhXcflK8PceuWfeNuaxI11IIfgfhNzkk70Xjc tSpg==
X-Gm-Message-State APt69E2wGw46XQ/pBa+vcVqYXuHcDCpZh8G8bumxt0+WOiYIyk6+DJsj L65X05c2+aELJN2VpAiEU9MOOq2v
X-Google-Smtp-Source AAOMgpc5a53HS4u/aJ2OC5E6gt53eT+s10Z2iVP1USqyU5EjGGu2kH+zD66dY7YUpkjdThaSv9OYJA==
X-Received by 2002:ac8:1bb8:: with SMTP id z53-v6mr21927094qtj.278.1531186719098; Mon, 09 Jul 2018 18:38:39 -0700 (PDT)
In-Reply-To <CA+n9pTy7vSPUA0j-bDF9_eWF0XysePRDAFckgvvHX8haSWv7KQ@mail.gmail.com>
X-Readdle-Message-ID c8ae5df2-b6b3-438f-bd99-4618f6b2d3c0@Spark
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2607:f8b0:400d:c0d::22f
Content-Disposition inline
X-Content-Filtered-By Mailman/MimeDel 2.1.21
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
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 <http://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>
Xref csiph.com gnu.bash.bug:14303

Show key headers only | View raw


The + is a unary operator, not part of the literal. Write $((+10#0034)) instead.

--
Clint
On Jul 9, 2018, 9:24 PM -0400, Isaac Marcos <isaacmarcos100010@gmail.com>, wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
> -DCONF_VENDOR
> uname output: Linux IO 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1
> (2018-05-07) x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
>
> Bash Version: 4.4
> Patch Level: 12
> Release Status: release
>
> Description:
> A value inside an arithmetic expansion is processed as octal despite using
> a 10# preffix.
>
> Repeat-By:
> $ echo $((10#+0034))
> 28
>
> Fix:
> Extract optional sign before parsing the number, re-attach after.
>
> --
> Cases are always threesome:
> Best case, Worst case, and Just in case

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


Thread

Re: Number with sign is read as octal despite a leading 10# Clint Hepner <clint.hepner@gmail.com> - 2018-07-09 21:37 -0400

csiph-web