[TriLUG] BASH oddity
Warren Myers
volcimaster at gmail.com
Tue Feb 21 17:31:56 EST 2006
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
More information about the TriLUG
mailing list