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


Groups > gnu.bash.bug > #14334 > unrolled thread

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

Started byRobert Elz <kre@munnari.OZ.AU>
First post2018-07-13 11:35 +0700
Last post2018-07-13 11:35 +0700
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

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

FromRobert Elz <kre@munnari.OZ.AU>
Date2018-07-13 11:35 +0700
SubjectRe: Number with sign is read as octal despite a leading 10#
Message-ID<mailman.3493.1531456556.1292.bug-bash@gnu.org>
    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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web