innova
08-15-2003, 12:32 PM
Hi,
I am trying to build a script and coming up against a stumbling block. I have a case statement that selects from #X options and carries out a function if the inputted variable matches...
The problem is, I wish to make my code modular, so I dont have to keep adding case statements for each additional thing.
I have a variable that stores a list of options that the script can take an action on.
I need to know how I can compare a single value against a list of values, and if so, call a given function.
For example:
if [ $variable == $list ]
then
variable_action
fi
Obviously this code doesnt work. I need to evaluate $list, get the list, and then check to see if the variable is in the list. If so, proceed with an install function. If not, log a useful error.
Hopelessly complicated :(
I am trying to build a script and coming up against a stumbling block. I have a case statement that selects from #X options and carries out a function if the inputted variable matches...
The problem is, I wish to make my code modular, so I dont have to keep adding case statements for each additional thing.
I have a variable that stores a list of options that the script can take an action on.
I need to know how I can compare a single value against a list of values, and if so, call a given function.
For example:
if [ $variable == $list ]
then
variable_action
fi
Obviously this code doesnt work. I need to evaluate $list, get the list, and then check to see if the variable is in the list. If so, proceed with an install function. If not, log a useful error.
Hopelessly complicated :(
