[Lazarus] Problem with TProcessUTF8 and filenames with spaces

Michael Van Canneyt michael at freepascal.org
Sat Dec 8 19:28:08 CET 2012



On Sat, 8 Dec 2012, zeljko wrote:

> On Saturday 08 of December 2012 17:07:57 Michael Van Canneyt wrote:
>> On Sat, 8 Dec 2012, zeljko wrote:
>>>> 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.
>>
>> I called my app from the console and all worked fine.
>>
>> TCustomApplication has no special treatment of spaces, it doesn't need
>> that. It just uses what it gets from the OS.
>>
>>> Besides that I'm not using only
>>> one param, it's combination of  short and long params. Only problem is
>>> param with spaces.
>>
>> Well, according to my tests, TCustomApplication works fine as you can see
>> from the output I posted. I use TCustomApplication, and often have spaces
>> in the arguments. Never had a problem, so I do not believe the issue is
>> there.
>>
>> Please post the output (by the tool) of
>>
>> For I:=0 to ParamCount do
>>    Writeln(Paramstr(i));
>>
>> This will shed some light on the issue.
>
> ahhhhhhh :) now I see. It works when I call my utility from console, but I've
> called my utility via script which have same name (but it's in $HOME/bin
> directory), so when such params are passed to script it calls
> /path_to_my_utility/myutility $@
> So shell kills quotes and passes garbage to the utility.

You can use $* normally ?

Michael.




More information about the Lazarus mailing list