On Sat, 8 Dec 2012, zeljko wrote:

Hi,

TCustomApplication, fpc-2.6.0

./mycmdtool --inputfile=myfile withspace.txt
GetOptionValue('i','inputfile') returns only "myfile"

That is normal.

same thing happens if I try:
./mycmdtool "--inputfile=myfile withspace.txt"
./mycmdtool --inputfile="myfile withspace.txt"
./mycmdtool --inputfile='myfile withspace.txt'

This is not normal.


How to fix this (have param value with space) ? Any workarounds if it's bug in
TCustomApplication or whatever ?

I created the following TCustomApplication program:

procedure TMyApplication.DoRun;
var
  ErrorMsg: String;
begin
  writeln(getoptionvalue('f','file'));
  Terminate;
end;

When run it prints the correct output:

araminta: >./tc --file='my file is here.txt'
my file is here.txt
araminta: >./tc '--file=my file is here.txt'
my file is here.txt
araminta: >./tc "--file=my file is here.txt"
my file is here.txt

So I doubt the problem is there. What gets printed if you do a

For I:=0 to ParamCount do
  Writeln(Paramstr(i));

Just to rule out TCustomApplication.

You mention TProcessUTF8, that is a complicating factor. You then need to see (using strace) what the calling app actually sends.
I suspect the problem is there.

Are you using the new 'parameters' or still the old 'CommandLine' ?
If the latter, then it is a safe bet that the problem is there.

Michael.

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to