What's the exact way to properly quote a single command line argument?
For example, I have some random text in a variable $X
. I need to quote it in a way so that if I call
system("program.exe " + $X_QUOTED);
then argv[1]
of my program.exe has to match original unquoted $X
imagine I have this program.exe:
int main(const char **argv, int){ puts(argv[1]); }
and the output of command: "program xxxx" is:
"test |test
what xxxx
has to literally be? I tried to add quotes and all that trickery, but then I can always add some other type of output that would break my approach to quote cmd line arguments.