bug-bash
[Top][All Lists]
Advanced

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

Re: leading zeros ignored by perl, ksh. not bash


From: Chet Ramey
Subject: Re: leading zeros ignored by perl, ksh. not bash
Date: Wed, 23 Jul 2014 14:29:33 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

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).

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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