bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Robert Elz
Subject: Re: Number with sign is read as octal despite a leading 10#
Date: Fri, 13 Jul 2018 11:35:00 +0700

    Date:        Tue, 10 Jul 2018 18:46:32 -0400
    From:        Isaac Marcos <address@hidden>
    Message-ID:  <address@hidden>


  |         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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]