I have a function like this
function test(){
local param1=${1}
local param2=${2}
echo "Hey ${param1} ${param2}"
}
And then, in another part of the script I have this
echo ${command}
$(command)
echo "Completed"
The output of that execution is
test param1 param2
Completed
So, as you can see, the function test was not executed.
I was looking a way to do that if possible in my shell script.
commandis a shell builtin which does nothing when called without any args (try runningcommandat the command prompt);$( command )says to run the (builtin)commandin a subshell ... which still does nothing; to reference the variablecommandtry$( $command )... not saying your code will work as expected but it should get you further along in the process; generally speaking ... naming variables, function and scripts with the same names as builtins and system executables (eg,testandcommand) isn't a recommended practicefunction test() {, see wiki.bash-hackers.org/scripting/obsolete. Modern POSIX-compliant function declaration syntax is justtest() {; 1980s ksh usedfunction test {with no(); merging the two gives you the worst of both worlds, as your code is compatible with neither legacy ksh nor baseline POSIX.testas your function name is probably best avoided, as it shadows the built-intestcommand.