Hi oocyte,
Yes, I probably did mean indirect reference, oops ! ;-)
Is it possible to do something with eval if I've only got access to the Bourhe sh shell ?
Main Topics
Browse All TopicsHi,
I'm having difficulty getting my head around indirect variables.
My goal in the code below is to set the "prog_mode" variable based upon the case test outcome.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Dear TwentyFourSeven,
Your solution does not appear to work. Running your code under Bourne shell yeilds the following error:
28: Bad substitution
running it under bash yields
line 15: =TRUE: command not found
The program changes that both oocyte and I offered you, however, do work under both Bourne and Bourne-again shells. The snippet written by oocyte will work in Bash simply by removing the last two lines and the changing the first line to #!/bin/sh.
Business Accounts
Answer for Membership
by: oocytePosted on 2009-11-05 at 05:38:48ID: 25749255
TwentyFourSeven, I have never heard about indirect variables, but I do know indirect variable reference, and that is what ${!var} notation means. So i'm not sure if the following if what you are looking for.
The ${!var} notation is only available in bash shell. So the first line have to be #!/bin/bash
So in the following:
$2=prog_mode
Then eval $2="TRUE" is effectively saying prog_mode="TRUE"
This method is available in all flavours of shell.
As for indirect variable reference, see example at bottom of script.
Select allOpen in new window