Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] command line parsing

On Tue, Feb 10, 2009 at 9:36 AM, Elena Laskavaia <elaskavaia@xxxxxxx> wrote:
Since no one cares, I did windows parsing in "cmd" (windows xp) style and unix parsing in "shell" (sh) style.
I am not sure how it will affect us since we send the commands from local Windows system to remote unix box. Also, we need to keep the same configuration to be used both from Windows and Linux. I may complain later. Also, Cygwin users may find "cmd" parsing irrational.


args         win          unix

/a/b/c d    [/a/b/c][d]   [/a/b/c][d]
\a\b\c d    [\a\b\c][d]   [abc][d]
\a\b\c d    [\a\b\c][d]   [abc][d]
"\a\b\c"    [\a\b\c]      [\a\b\c]
"a b"       [a b]         [a b]
'"q"'       ['q']         ["q"]
\"a\"       ["a"]         ["a"]  Note: even quotes are passed to spawner - windows spawner removes them, maybe need double escape in this case

Due to API restrictions variable substitution happens _before_ arg splitting, so if project location has spaces it has to be double quoted, i.e.

${project_loc}/path  [C:/workspace/project][a/path]
"${project_loc}/path"  [C:/worskapce/project a/path]

Elena Laskavaia wrote:
In CDT we have couple places where we have to parse command line arguments,
make commands args and launch command args.
Pre-5.0 it was very inconsistent and broken (the way quotes, spaces and other non-trivial case were parsed).
I fixed it 5.0.2 and now it consistent and work as unix "shell" command line parsing works.
With one problem. Windows. On windows "\" can be used in path names and therefore cannot be used as escape character.
I forgot about that. So we have a dilemma - do we use 2 different way of escaping command line on windows and linux, or
use linux one - but with complications on windows (i.e user would have to use \\ to escape \ or unquote this) or
come up with some 3rd schema which would cover both (which I am not aware of now).

original bug

windows \ expansions bug
cdt-dev mailing list
cdt-dev mailing list

Back to the top