[Lazarus] Parsing command line options

J.A. de Vries hdv.jadev at gmail.com
Mon Sep 10 17:19:35 CEST 2012

On 2012-09-10 15:19, patspiper wrote:

>> 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!

Might I make a suggestion? Why try and invent the wheel ourselves?
There's a very good library named getopts that has been used by masses
of programmers for years now. Maybe we could learn from that and
re-implement the choices made in there?

Grx HdV

More information about the Lazarus mailing list