what does it take to make my program accept command-line arguments with spaces?
Yet-another EDIT: I have just recognized that the program is started from a shell-script that sets up the environment for the execution of the program. As there are some external libraries, LD_LIBRARY_PATH is set to the current working directory:
#!/bin/sh
ARCH=`uname -m`
export LD_LIBRARY_PATH=".:lib/magic/linux-${ARCH}"
./data_sniffer.bin $*
exit $?
The issue is definitely related to $*. Is there any solution to correctly forward the command-line parameters?
Here is a code-snippet from main():
if (stat(argv[1], &lStat) != 0)
{
fprintf(stderr, "Cannot stat(2) given file: %s. \n", argv[1]);
return EXIT_FAILURE;
}
I am starting my program with the following parameters:
./data_sniffer /mnt/pod/movies/some\ test\ movie\ file.avi
The resulting error message looks like this: Cannot stat(2) given file: /mnt/pod/movies/some.
Anyone an idea what's wrong here? I think that I am not the first one with this problem (though, I could not find a related question here).