[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] declare -i
From: |
Dan Douglas |
Subject: |
Re: [Help-bash] declare -i |
Date: |
Wed, 09 May 2012 21:30:47 -0500 |
User-agent: |
KMail/4.8.3 (Linux/3.3.4-pf+; KDE/4.8.3; x86_64; ; ) |
On Wednesday, May 09, 2012 07:18:51 PM Bill Gradwohl wrote:
>
> On Wed, May 9, 2012 at 2:55 PM, Greg Wooledge <address@hidden> wrote:
>
> Math contexts do an infinitely-recursing indirect parameter expansion
> thingy:
>
> imadev:~$ a=b b=c c=d d=e e=f f=42; echo $((a))
> 42
>
>
> Didn't know that you could write a=b b=c c=d d=e e=f f=42; as one statement.
> I'll have to play with that to figure out who sets the return code (last I
> presume), and if there's an assumed connector in between each expression. Is
> there any return code checking from one to the next? I'll figure it out.
There's no "return codes". If a variable isn't a number then bash tries to
resolve it recursively until it finds something that is.
> Didn't know about the infinite recursive expansion either.
It's limited to 1024.
> Thank You
>
> The infinite recursion could come in handy in a non arithmetic context as
> well. Why can't we have it everywhere?
It's used unintentionally more often than intentionally. I have a few uses for
it which search at most a couple levels. You definitely don't want this
everywhere.
Print Fibbonacci: a=('a[a[n]=a[n-1]+a[n-2],n++/94]' 2 0 1); echo
"address@hidden:n=4,a}"
> This brings to mind what happened the other day. I tried array[-1]=blahBlah
> and couldn't figure out what it was complaining about. A Google search
> finally told me that's illegal on the left hand side. I guess I never tried
> that before. I didn't notice anything in man bash about it.
>
> I'd like the infinite recursion everywhere and [-1] on the left hand side as
> examples of consistency as opposed to the exceptions they are currently.
>
> --
> Bill Gradwohl
See my last mail. Bash can't do it (yet).
--
Dan Douglas
signature.asc
Description: This is a digitally signed message part.
- Re: [Help-bash] declare -i, (continued)
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/09
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/09
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/09
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/09
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/09
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/09
- Re: [Help-bash] declare -i, DJ Mills, 2012/05/09
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/09
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/09
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/09
- Re: [Help-bash] declare -i,
Dan Douglas <=
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/10
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/10
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/10
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/10
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/10
- Re: [Help-bash] declare -i, Dan Douglas, 2012/05/10
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/10
- Re: [Help-bash] declare -i, Clark WANG, 2012/05/09
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/09
- Re: [Help-bash] declare -i, lxnf98mm, 2012/05/09