|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-12-09 22:49:35
"Eric Boutin" <eric_at_[hidden]> writes:
> Hi ! If you didn't knew already, under windows, I didn't tested all
> compiler, but vc++ 6.0 have this issue, well system(const char*) is buggy:
> you have to double-quote the command to execute.
>
> Example
> instead of
> string callstring = " \"c:\\Program File\\a program\\a executable.exe\"
> \"--a argument\"";
> system(callstring.c_str() );
> ( cout << callstring would produce : "c:\Program File\a program\a
> executable.exe" "--a argument" )
>
>
> you have to do
> string callstring(" \"\"c:\\Program File\\a program\\a executable.exe\"
> \"--a argument\""\");
> system(callstring.c_str() );
> (cout << callstring would produce : " "c:\Program File\a program\a
> executable.exe" "--a argument" ")
>
>
> i.e. you have to produce:
> " "a file containing whitespace" "-a argument" "
>
> I didn't tested this issue under all os, since microsoft are the only one
> who had the idea to put whitespace in filename
All the filesystems I know about can have whitespace in file and
directory names. Why don't you try it on some other OSes, just for
laughs?
> therefore, it would be nice to have a macro BOOST_BUGGY_SYSTEM to know if we
> have to double-quote the system( ) calls
Are you sure it's a bug? I doubt the standard says much about the
legal contents of a string used in a call to system( ).
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk