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


Groups > gnu.bash.bug > #14334

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

Path csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Robert Elz <kre@munnari.OZ.AU>
Newsgroups gnu.bash.bug
Subject Re: Number with sign is read as octal despite a leading 10#
Date Fri, 13 Jul 2018 11:35:00 +0700
Lines 23
Approved bug-bash@gnu.org
Message-ID <mailman.3493.1531456556.1292.bug-bash@gnu.org> (permalink)
References <CA+n9pTxfKTmmqPabZ+XMqk4PPhiX4x_yQy-W6TnyndR3iBO-HA@mail.gmail.com> <CA+n9pTy7vSPUA0j-bDF9_eWF0XysePRDAFckgvvHX8haSWv7KQ@mail.gmail.com> <c8ae5df2-b6b3-438f-bd99-4618f6b2d3c0@Spark> <71850c03-54d3-6a7e-1d29-136950d9e139@iki.fi> <a0b100e7-3e14-e56e-8ffb-fcaeca587bf1@case.edu> <CA+n9pTwOZNdmWqEYwE5cDohArgvZ285vSt-F=hw=ZGb8weO2qA@mail.gmail.com> <471822f3-4484-59b5-0433-fc394dc9b34a@case.edu> <CA+n9pTzNU4stJykWKAJkPzwwrkmxzirWmuUT_xA9U=ZWsh3nMQ@mail.gmail.com> <CAOSMAutyKDe7QqVHLQ_jFBzZ09hiOwz_LfkoCVYXpDGVNohm0Q@mail.gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1531456556 21785 208.118.235.17 (13 Jul 2018 04:35:56 GMT)
X-Complaints-To action@cs.stanford.edu
Cc Eduardo Bustamante <dualbus@gmail.com>, bug-bash <bug-bash@gnu.org>, bash@packages.debian.org, Chet Ramey <chet.ramey@case.edu>
To Isaac Marcos <isaacmarcos100010@gmail.com>
Envelope-to bug-bash@gnu.org
In-Reply-To <CA+n9pTxfKTmmqPabZ+XMqk4PPhiX4x_yQy-W6TnyndR3iBO-HA@mail.gmail.com>
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2001:3c8:9009:181::2
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:14334

Show key headers only | View raw


    Date:        Tue, 10 Jul 2018 18:46:32 -0400
    From:        Isaac Marcos <isaacmarcos100010@gmail.com>
    Message-ID:  <CA+n9pTxfKTmmqPabZ+XMqk4PPhiX4x_yQy-W6TnyndR3iBO-HA@mail.gmail.com>


  |         set -- 34 034 0034 +34 +034 +0034 -34 -034 -0034 ;
  |         for i do printf '%6s' "$((10#$i))"; shift; done; echo

You really ought be only using POSIX defined sh operators,
from two more POSIX compatible shells (in this regard...):

jinx$ sh -c 'printf '%6s' "$((10#$i))"'
sh: arithmetic: unexpected '#' (0x23) in expression
jinx$ fbsh !*
fbsh -c 'printf '%6s' "$((10#$i))"'
fbsh: arithmetic expression: expecting EOF: "10#"

Leading "base#" is not part of the sh language at all, and so
should not be expected to work at all, let alone in any particular way.

kre

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


Thread

Re: Number with sign is read as octal despite a leading 10# Robert Elz <kre@munnari.OZ.AU> - 2018-07-13 11:35 +0700

csiph-web