I am trying to wrap a shell script so that it may be called from a Windows program inside Cygwin. Following up on a previous question, I thought it was enough to pass the arguments of the script to the wrapper as follows:
#include <stdlib.h>
#include <unistd.h>
int
main (int argc, char *argv[])
{
/* WARNING: Only use an absolute path to the script to execute,
* a malicious user might fool the binary and execute
* arbitary commands if not.
* */
system ("~/bin/script.sh \"$*\"");
return 0;
}
The script runs, but somehow cannot pass the arguments to the wrapper (I guess?). Coming from a DOS/Win background, this shell scripting thing is somewhat mysterious to me. What is wrong with this approach?
argvarray that was passed tomain, and add each parameter from there (separated by spaces) to the string you pass tosystem().system()function simply passes the argument to the OS, missing some capabilites of the shell, if any...