addr...@hidden (Re: indirection as an lvalue)

2009-04-25 Thread Bob Proulx
Bill Gradwohl wrote: > BTW - I ran thru the archives via a search for 'indirection' and for the > longest time was confused by references to addr...@hidden scattered > throughout the code examples. Here's an example: > http://lists.gnu.org/archive/html/bug-bash/2002-11/msg00085.html > > I did a ma

Re: indirection as an lvalue

2009-04-24 Thread Andreas Schwab
Bill Gradwohl writes: > I tried it with and without and it doesn't appear to make a difference. Try adding spaces or other special characters to the value of $makeTempFileName. The variable should be expanded during the rescan done by eval, not before. Andreas. -- Andreas Schwab, sch...@linu

Re: indirection as an lvalue

2009-04-24 Thread Bill Gradwohl
On Fri, 2009-04-24 at 19:54 +0200, Andreas Schwab wrote: > Use eval. > >eval $x=\${makeTempFileName} After you mentioned it, I remembered reading about eval a long time ago and couldn't understand what it was good for. Now I know. Thank You. Why the backslash before the $ ? I tried it with

Re: indirection as an lvalue

2009-04-24 Thread Andreas Schwab
Bill Gradwohl writes: > My real world need is to assign temporary file names to named variables. > > makeTempFileName='' > for x in 'TEMPLOG' 'TEMPFILELEFT' 'TEMPFILERIGHT'; do >makeTemp "${x}" # function that does a lot of processing and > # sets makeTempFileName equal

Re: indirection as an lvalue

2009-04-24 Thread Greg Wooledge
On Fri, Apr 24, 2009 at 11:49:43AM -0600, Bill Gradwohl wrote: > This is a trivial example, but gives you the idea. > for x in 'VAR_A' 'VAR_B' 'VAR_C'; do ># What I'd like to say is >!x="hello" > done In bash 4, you can use associative arrays, which gives you what you really want. Apart

indirection as an lvalue

2009-04-24 Thread Bill Gradwohl
It appears that indirection can only be used as an rvalue. Is there any way to use indirection as an lvalue? This is a trivial example, but gives you the idea. for x in 'VAR_A' 'VAR_B' 'VAR_C'; do # What I'd like to say is !x="hello" done resu