Hi folks, I'm writing a wrapper for a fairly large selection of scripts, that are normally executed something like
Code:
$BIN/script -arg ARG -args "ARG1 ARG2"
but i want to do something else with the output, like=
Code:
$BIN/scriptX -arg ARG -args "ARG1 ARG2" | dosomething -name="scriptX"
Which works fine for one or two cases, but applying this accross the board i would rather do this in a globally defined function, like
Code:
function run() {
SCRIPT=`basename $1`
COMMAND=$*
{
$COMMAND
} | dosomething -name=$SCRIPT
run $BIN/scriptX -arg ARG -args "ARG1 ARG2"
but when i check this out, its actually executing
Code:
$BIN/scriptX -arg ARG -args ARG1 ARG2 | dosomething -name=scriptX
As you can see, the double quotes are processed by bash and summarily ignored.
While i could go and escape every single quote in the codebase, i would rather not.
I've tried changing the execution format to eval, exec, weird subshells, using $@ instead of $*, and im out of ideas.
Does anyone know how this could be accomplished?