[TriLUG] BASH oddity
Paul G. Szabady
Paul at ThyService.com
Tue Feb 21 18:02:10 EST 2006
That's what I thought, but other non-octal combinations work.
IE
[paul at at paul]$ declare -i dirx=88 ; echo $dirx
88
[paul at at paul]$
--
Paul
@ Thy Service
> I believe it is interpreting the '08' as an octal string, and '8' does not
> exist in octal (only 0..7).
>
> Warren
>
> On 2/21/06, Paul G. Szabady <Paul at thyservice.com> wrote:
>>
>> Greetings,
>>
>> I'm trying to write a script and find something confusing. If you look
>> at
>> the examples below, I was using #2. It works if I manually set it to
>> '8',
>> but not '08'. It works with both '6' and '06'.
>>
>> So, what's special about '08'?
>>
>> #1
>> [paul at at paul]$ declare -i dirx=$(date +%g)
>> [paul at at paul]$ echo $dirx
>> 6
>>
>>
>> #2
>> [paul at at paul]$ declare -i dirx=$(date +%V)
>> -bash: declare: 08: value too great for base (error token is "08")
>> [paul at at paul]$ echo $dirx
>> 6
>>
>>
>> #3
>> [paul at at paul]$ declare -i dirx=08
>> -bash: declare: 08: value too great for base (error token is "08")
>> [paul at at paul]$ echo $dirx
>> 6
>>
>>
>> #4
>> [paul at at paul]$ declare -i dirx=8
>> [paul at at paul]$ echo $dirx
>> 8
>>
>>
>> #5
>> [paul at at paul]$ declare -i dirx=06
>> [paul at at paul]$ echo $dirx
>> 6
>>
>>
>>
>> [paul at at paul]$ export thisweek=(date +%g) ; echo $thisweek
>> (date +%g)
>> [paul at at paul]$ export thisweek=$(date +%g) ; echo $thisweek
>> 06
>> [paul at at paul]$ export thisweek=$(date +%V) ; echo $thisweek
>> 08
>> [paul at at paul]$
>>
>>
>>
>> --
>> Paul
>> @ Thy Service
>>
>>
>> --
>> TriLUG mailing list :
>> http://www.trilug.org/mailman/listinfo/trilug
>> TriLUG Organizational FAQ : http://trilug.org/faq/
>> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
>>
>
>
>
> --
> http://warrenmyers.com
> "God may not play dice with the universe, but something strange is going
> on
> with the prime numbers." --Paul Erdõs
> "It's not possible. We are the type of people who have everything in our
> favor going against us." --Ben Jarhvi, Short Circuit 2
> --
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
More information about the TriLUG
mailing list