OK, I just figured out what was the cause of this problem.

In SysUtils.ExecuteProcess you were wrapping ppcbin compiler filename (like '/usr/local/ppc386') inside quotes (to make it something like '"/usr/local/ppc386"') but you were not stripping those quotes anywhere before passing this to execve (i.e. FpExecVE). So it shouldn't work (since execve should not tolerate any additional quotes in filename, even if it does on some UNIXes).

Patch to rtl/unix/unixutil.pp attached with (too many?) comments, it modifies StringToPPChar behavior so that it strips those quotes.

Regards,
Michalis
Index: unixutil.pp
===================================================================
RCS file: /FPC/CVS/fpc/rtl/unix/unixutil.pp,v
retrieving revision 1.3
diff -c -r1.3 unixutil.pp
*** unixutil.pp 3 Nov 2003 09:42:28 -0000       1.3
--- unixutil.pp 12 Feb 2004 18:25:43 -0000
***************
*** 76,81 ****
--- 76,95 ----
    Create a PPChar to structure of pchars which are the arguments specified
    in the string S. Especially usefull for creating an ArgV for Exec-calls
    Note that the string S is destroyed by this call.
+   
+   Quotes (") are stripped from arguments.
+   WARNING: This function strips quotes from arguments but it does NOT
+   parse S properly, e.g. when S = '"foo bar"' it will be (incorrectly) 
+   splitted to TWO arguments: '"foo' and 'bar"'. To solve this elegantly
+   one should parse S correctly (taking care NOT to break arguments at
+   spaces between quotes) and one should specify how quotes that should
+   make their way into final arguments should be safely encoded in S 
+   (e.g. as '\"' ? How do we encode '\' then, as '\\' ?). 
+   
+   I guess it's not so important because functions StringToPPChar are needed 
+   (only?) for deprecated functions Execl and such in module Unix.
+   That's why FpExecL are better then their counterparts without "Fp":
+   they don't have this problem.
  }
  
  begin
***************
*** 99,104 ****
--- 113,121 ----
    nr  : longint;
    Buf : ^char;
    p   : ppchar;
+   
+   TempP, Result:ppchar;
+   Len:Integer;
  
  begin
    buf:=s;
***************
*** 112,118 ****
        inc(buf);
     end;
    getmem(p,nr*4);
!   StringToPPChar:=p;
    if p=nil then
     begin
       {$ifdef xunix}
--- 129,136 ----
        inc(buf);
     end;
    getmem(p,nr*4);
!   Result:=p;
!   StringToPPChar:=Result;
    if p=nil then
     begin
       {$ifdef xunix}
***************
*** 134,139 ****
--- 152,170 ----
       while not (buf^ in [' ',#0,#9,#10]) do
        inc(buf);
     end;
+ 
+  { strip quotes (") around arguments }
+  TempP:=Result;
+  while TempP^ <> nil do
+  begin   
+   Len := StrLen(TempP^);  
+   if (Len>1) and (TempP^[0] = '"') and (TempP^[Len-1] = '"') then
+   begin
+    TempP^[Len-1] := #0; { delete last " }
+    Inc(TempP^);         { delete first " }
+   end;
+   Inc(TempP);
+  end;
  end;
  
  

Reply via email to