[Gllug] bash indirect variable referencing ugliness

Daniel P. Berrange dan at berrange.com
Tue Nov 21 15:41:39 UTC 2006


On Tue, Nov 21, 2006 at 03:45:38PM +0000, Julian Somers wrote:
> Take a deep breath, hold your nose, and scroll down to my hideous hack
> to do indirect variable reference in this bash script.
> 
> Is there a more elegant way to do this? I wrote it yesterday, and
> already I have forgotten what half of those evals and backtics are for!
> I hate to think what I'll make of it in a month's time.

Yes, just use Perl[1] instead. If you find yourself trying to do 
complex programming in bash, it is a sure sign that you shouldn't
be using bash :-)


Regards,
Dan.

[1] Or insert other real scripting language of choice if Perl
    scares you too much.
-- 
|=-            GPG key: http://www.berrange.com/~dan/gpgkey.txt       -=|
|=-       Perl modules: http://search.cpan.org/~danberr/              -=|
|=-           Projects: http://freshmeat.net/~danielpb/               -=|
|=-   berrange at redhat.com  -  Daniel Berrange  -  dan at berrange.com    -=|
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list