I have a user supplied script like
#!/bin/sh
some_function () {
touch some_file
}
some_other_function () {
touch some_other_file
}
and i want to call the function some_other_function from c-code.
I understand, that i could simply write a shell script like
#!/bin/sh
source userscript.sh
some_other_function
and execute it using system(), but i am looking for a more elegant and especially a more generic solution, that lets me execute arbitrarily named functions and maybe even lets me get/set variables.
execan external program/shell, soexec('sh yourscript.sh foo bar baz');, basically, wherefoo bar bazbecome arguments to your external script.bash -c ". myfuncs.sh ; call_to_func arg1"/bin/shisn'tbash(well, technically it might be provided bybash, but it's not the same thing).