Bug 431350 - error using date in bash
Summary: error using date in bash
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: 8
Hardware: i386
OS: Linux
low
low
Target Milestone: ---
Assignee: Tomas Janousek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-02-03 09:56 UTC by vikram goyal
Modified: 2008-02-04 16:38 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2008-02-04 16:38:04 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description vikram goyal 2008-02-03 09:56:45 UTC
Description of problem:


Version-Release number of selected component (if applicable):
bash-3.2-20.fc8
coreutils-6.9-12.fc8

How reproducible:


Steps to Reproduce:
1.TEST=8
2.echo $(($(echo $TEST)-1)) - executes
3.echo $(($(date +'%H')-1)) - executes
4.echo $(($(date +'%y')-1)) - error
5.echo $(($(date +'%m')-1)) - same error if month is AUGUST

Actual results:
bash: 08: value too great for base (error token is "08")

Expected results:
In the year 2008, the answer should be 7

Additional info:
The problem could be in date or bash.
The problem is long standing, maybe about 3-4 year. Had reported earlier also, a
long time back.

Comment 1 Tomas Janousek 2008-02-04 09:46:36 UTC
Is there any documentation that would suggest this is a violation of some
standard or something? bash interprets numbers beginning with zero as octal
numbers. The date manpage says that when using the '-' flag, numbers are not
zero-padded.

The following commands work:
> echo $(($(date +'%-y')-1))
> echo $(($(date +'%-m')-1))

May I close this notabug?

Comment 2 vikram goyal 2008-02-04 16:31:10 UTC
You are right. My bad. Sorry for bothering you. I never came to understand the
error message as it was not clear enough. But one thing is still unclear, why
does it happen when the output is 08 only. The command runs without error if
output is less than 08 or ( as far as  remember ) above 10, I think.

You may of course close the bug except that one issue.

Comment 3 Tomas Janousek 2008-02-04 16:38:04 UTC
Well, 07 is a valid octal number, right? And 10 is not interpreted as octal,
obviously.


Note You need to log in before you can comment on or make changes to this bug.