Hello.
Looking for a method of modularizing my bash script, I am stuck with such a problem. For example, I have:
MODULE_NAME="test"
FUNCTION_NAME="run"
How do I can a function with name test_run?
Hello.
Looking for a method of modularizing my bash script, I am stuck with such a problem. For example, I have:
MODULE_NAME="test"
FUNCTION_NAME="run"
How do I can a function with name test_run?
Something like this:
MODULE_NAME="test"
FUNCTION_NAME="run"
eval ${MODULE_NAME}_${FUNCTION_NAME}
Regards
Thanks a lot!
Here is one way. I have not put test_run is a separate file but that is probably what you want to do and then source that file
so that test_run is available in your script.
#!/usr/local/bin/bash
function test_run
{
echo "In test_run ....."
}
MODULE_NAME="test"
FUNCTION_NAME="run"
${MODULE_NAME}_${FUNCTION_NAME}
Wow... This works even without eval! Thanks a lot!