I'm trying to create a function method in a bash script that executes a command which is supplied to the method by the paramters.Meaning somethings like this:special_execute(){    # Some code    # Here's the point where the command gets executed    $@    # More code}special_execute echo abcI already tried I $@, $@, $*, $* how could I do that?
Execute command supplied by function parameters
bash;command;function;parameter;bash script
I think it's just a quoting issue when you're passing the arguments into the function.Try calling it like so:$ special_execute echo 'abc''abc'If you don't want the single quotes around abc then change the quoting like this:$ special_execute echo abcabcDebuggingYou can wrap the internals of the function so that it echoes out with more verbosity.$ function special_execute() { set -x; $@; set +x; }Then when you run commands through the function, special_execute you can see what's going on.ps example:$ special_execute ps -eaf+ ps -eafUID        PID  PPID  C STIME TTY          TIME CMDroot         1     0  0 Aug21 ?        00:00:01 /sbin/initroot         2     0  0 Aug21 ?        00:00:00 [kthreadd]...perl example:$ special_execute perl -MTime::HiRes=sleep -le 'for(1..10) { print; sleep 0.05; }'+ perl -MTime::HiRes=sleep -le 'for(1..10) { print; sleep 0.05; }'12345678910+ set +xParsing argument $1You could do something like this to parse any arguments passed in as $1.$ function special_execute() {     [ $1 -eq -123 ] && echo flagY || echo flagN;     shift;     set -x; $@; set +x;   }Examplewith debugging enabled:$ special_execute -123 perl -MTime::HiRes=sleep -le 'for(1..5) { print; sleep 0.05; }'flagY+ perl -MTime::HiRes=sleep -le 'for(1..5) { print; sleep 0.05; }'12345+ set +xwith debugging off - -123:$ special_execute -123 perl -MTime::HiRes=sleep -le 'for(1..5) { print; sleep 0.05; }'flagY12345with debugging off - -456:$ special_execute -456 perl -MTime::HiRes=sleep -le 'for(1..5) { print; sleep 0.05; }'flagN12345