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#

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 2018-07-13 11:35 +0700
Message-ID <mailman.3493.1531456556.1292.bug-bash@gnu.org> (permalink)
References (4 earlier) <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>

Show all headers | 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