[Lazarus] Problem with TProcessUTF8 and filenames with spaces

zeljko zeljko at holobit.net
Sat Dec 8 16:41:43 CET 2012


On Saturday 08 of December 2012 12:30:03 Michael Van Canneyt wrote:
> 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.

I'm using what TCustomApplication offers: HasOption and GetOptionValue.
TProcessUTF8 isn't guilty here definitelly since I'm calling my utility from 
application with it, but my utility in console returns bad results, so 
something with TCustomApplication could be. Besides that I'm not using only 
one param, it's combination of  short and long params. Only problem is param 
with spaces.

zeljko




More information about the Lazarus mailing list