Opened 9 years ago

Last modified 4 years ago

#8535 new Bugs

problem with paths that have whitespace in boost::program_options

Reported by: bdahi@… Owned by: Vladimir Prus
Milestone: To Be Determined Component: program_options
Version: Boost 1.53.0 Severity: Problem
Keywords: path, empty space, program_options Cc: mail@…

Description

This seems to be a known bug since at least 2008. Full description and suggested solution is mentioned in the external link below:

[boost.2283326.n4.nabble.com/program-options-Problem-with-paths-that-have-spaces-td2576490.html]

In short: when a boost::filesystem::path is used directly to retrieve a path parameter, if the path has a whitespace -- regardless of whether / or \ is used, or the whitespace is escaped, or the path is double-quoted -- a parsing error occurs.

The current workaround is to use string and then convert that to boost::filesystem::path using the = operator of the path class, however this looks more of a "bug" in program_options rather than new feature in lexical_cast module since in program_options lexical casting of string to path is obviously failing and should not have been considered.

Change History (7)

comment:1 by Georg Sauthoff <mail@…>, 9 years ago

Cc: mail@… added

comment:2 by Vladimir Prus, 9 years ago

Why is this a program_options problem, as opposed to filesystem problem, as I've explained back then?

comment:3 by anonymous, 7 years ago

I've just hit this bug in 1.59.0, and it's quite annoying. I've read through the thread on the boost mailing list and also https://groups.google.com/forum/#!topic/boost-list/TGrrvSWkpoE. Do you think you could sit together with the people from filesystem and/or lexical_cast and implement a solution? That should not be impossible. It would be great, as it's in my opinion quite a serious limitation, and the workaround via string is ugly and non-idiomatic.

comment:4 by anonymous, 6 years ago

As an end user of boost program options funcionality, split_winmain not splitting a command line correctly is a program options problem

comment:5 by anonymous, 6 years ago

Is there a fix for this yet?

comment:6 by Vizor, 5 years ago

I think, it's showstopper for file path arguments, there is very high chance, that path will contain spaces.

comment:7 by anonymous, 4 years ago

I have encountered it too in 1.67.0. It's really annoying that I have to change path into string.

Note: See TracTickets for help on using tickets.