[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: leading zeros ignored by perl, ksh. not bash
From: |
Dan Douglas |
Subject: |
Re: leading zeros ignored by perl, ksh. not bash |
Date: |
Wed, 23 Jul 2014 15:49:56 -0500 |
On Wed, Jul 23, 2014 at 1:29 PM, Chet Ramey <chet.ramey@case.edu> wrote:
> On 7/23/14, 3:20 AM, Maik.Liedtke@sungard.com wrote:
>> hello,
>>
>> to change our scripts from ksh to bash we have problems with vars and
>> leading zeros.
>> how we can declare hrs and min?
>
> Greg offered several good suggestions to force base 10 in certain
> situations.
>
>> or can we disable the automatic change from decimal to octal?
>
> No. Bash treats integer constants identically regardless of the context: a
> leading 0 denotes octal. ksh93 treats constants with leading zeros
> differently in different contexts (assigning to a variable with the integer
> attribute set happens to be one of the cases where ksh93 treats a constant
> as strictly decimal).
I don't believe there are any cases in which ksh interprets a leading
zero, at least not current versions. If you want octal you must use
either 8#num or typeset -ibase. Same applies to both zsh and mksh
AFAICT.