Strange assignment - new version (UNCLASSIFIED)

Glasgow, Steven Mr CIV USA TRADOC Steven.Glasgow at us.army.mil
Mon Jan 3 18:23:25 UTC 2011


Classification: UNCLASSIFIED
Caveats: NONE

"...a leading zero is the well-understood way to denote an octal value
on Unix and Linux systems." - is this something new since RHEL 4.7 using
tcsh or csh?

Steve

-----Original Message-----
From: redhat-list-bounces at redhat.com
[mailto:redhat-list-bounces at redhat.com] On Behalf Of Jonathan S Billings
Sent: Monday, January 03, 2011 10:56 AM
To: redhat-list at redhat.com
Subject: Re: Strange assignment - new version (UNCLASSIFIED)

On 01/03/2011 11:27 AM, Glasgow, Steven Mr CIV USA TRADOC wrote:
> RHEL 5.4:
>
>
> @ D=44 ; echo $D returns 44
> @ D=044 ; echo $D returns 36 --- HUH?
> @ D=08 ; echo $D returns @: Badly formed number --- HUH?
>
>
> Seems to be an octal thing going on.  Would anyone be able to shed 
> some light on this and how I might get 5.4 to act more like 4.7?

To be honest, I wasn't able to reproduce this behavior on my RHEL5.5
system with the bash-3.2-24.el5.x86_64 package:
% D=08; echo $D
08

However, I remember having problems with using 'date "+%H"' and then
using the -gt greater-than comparisons, because date zero-spaced the
hour and 8AM was "08".  I ended up fixing it by using %k instead of %H.

Bash now interprets numbers starting with a 0 as octal.  This is common
in other languages as well.  You could force the encoding by using 10#08
I believe, however I don't believe there is a way to disable this
behavior, since a leading zero is the well-understood way to denote an
octal value on Unix and Linux systems.

-- 
Jonathan Billings <jsbillin at umich.edu>
College of Engineering - CAEN - Unix and Linux Support

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
Classification: UNCLASSIFIED
Caveats: NONE






More information about the redhat-list mailing list