[Lazarus] Parsing command line options

patspiper patspiper at gmail.com
Mon Sep 10 15:19:19 CEST 2012

On 10/09/12 14:18, Marco van de Voort wrote:
> On Sat, Sep 08, 2012 at 10:34:37PM +0300, patspiper wrote:
>>> Depends. Split arguments for TProcess use (like in the above bugreport):
>>> afaik none. Simply keep all arguments separate and pass them to the
>>> "parameters" propery.
>> Keeping arguments separate may not be possible:
> Not *easily* possible. Not impossible.
Martin is currently investigating this venue.
>> http://permalink.gmane.org/gmane.comp.ide.lazarus.general/64781
> That's why the old option is still available "deprecated" for a while. But
> no new functionality will be added. IOW it will remain compatible to how it
> was when it was deprecated (2.6.0 compatible).
> If you can't change it out of compatibility, this will be no problem, since
> the current interface should be exactly compatible to 2.6.0 and before.
>> However, splitting the command line with the separator being an unquoted
>> space should be good enough.
> No it wouldn't, since  -xx="bla" needs to be dequoted on windows (and I
> assume OS/2) too.
> Your message is a very good example why the whole splitting and escaping
> approach was abandonned.  Every issue was considered to be "just add this,
> since then it works for me now", but after multiple years of such changes,
> there are still corner cases left.
Separating based on unquoted spaces is the 1st step. The 2nd step is to 
remove the 1st and last matching quote from each parsed parameter (even 
on *nix). The 3rd step is to add each parameter using 
TProcess.Parameters.Add. It is kind of a middle ground though I 
definitely support your suggestion if doable. Parsing a command line is 
a can of worms!


More information about the Lazarus mailing list