Procedure CommandToList(S : String; List : TStrings);
Procedure CommandToList(S : String; List : TStrings);
{$ifdef unix}
{$ifdef unix}
Var
Var
TryTerminals : Array of string;
TryTerminals : Array of string;
XTermProgram : String;
XTermProgram : String;
Function DetectXTerm : String;
Function DetectXTerm : String;
{$endif unix}
{$endif unix}
function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string;var exitstatus:integer):integer;
function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string;var exitstatus:integer):integer;
function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string):boolean;
function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string):boolean;
function RunCommandInDir(const curdir,cmdline:string;var outputstring:string):boolean; deprecated;
function RunCommandInDir(const curdir,cmdline:string;var outputstring:string):boolean; deprecated;
function RunCommand(const exename:string;const commands:array of string;var outputstring:string):boolean;
function RunCommand(const exename:string;const commands:array of string;var stdout:string):boolean; overload;
function RunCommand(const cmdline:string;var outputstring:string):boolean; deprecated;
function RunCommand(const exename:string;const commands:array of string;var stdout,stderr:string):boolean; overload;
function RunCommand(const cmdline:string;var outputstring:string):boolean; overload; deprecated;
implementation
implementation
{$i process.inc}
{$i process.inc}
Procedure CommandToList(S : String; List : TStrings);
Procedure CommandToList(S : String; List : TStrings);
Function GetNextWord : String;
Function GetNextWord : String;
Const
Const
WhiteSpace = [' ',#9,#10,#13];
WhiteSpace = [' ',#9,#10,#13];
Literals = ['"',''''];
Literals = ['"',''''];
Var
Var
Wstart,wend : Integer;
Wstart,wend : Integer;
InLiteral : Boolean;
InLiteral : Boolean;
LastLiteral : char;
LastLiteral : char;
begin
begin
WStart:=1;
WStart:=1;
While (WStart<=Length(S)) and (S[WStart] in WhiteSpace) do
While (WStart<=Length(S)) and (S[WStart] in WhiteSpace) do
Inc(WStart);
Inc(WStart);
WEnd:=WStart;
WEnd:=WStart;
InLiteral:=False;
InLiteral:=False;
LastLiteral:=#0;
LastLiteral:=#0;
While (Wend<=Length(S)) and (Not (S[Wend] in WhiteSpace) or InLiteral) do
While (Wend<=Length(S)) and (Not (S[Wend] in WhiteSpace) or InLiteral) do
begin
begin
if S[Wend] in Literals then
if S[Wend] in Literals then
If InLiteral then
If InLiteral then
InLiteral:=Not (S[Wend]=LastLiteral)
InLiteral:=Not (S[Wend]=LastLiteral)
else
else
begin
begin
InLiteral:=True;
InLiteral:=True;
LastLiteral:=S[Wend];
LastLiteral:=S[Wend];
end;
end;
inc(wend);
inc(wend);
end;
end;
Result:=Copy(S,WStart,WEnd-WStart);
Result:=Copy(S,WStart,WEnd-WStart);
if (Length(Result) > 0)
if (Length(Result) > 0)
and (Result[1] = Result[Length(Result)]) // if 1st char = last char and..
and (Result[1] = Result[Length(Result)]) // if 1st char = last char and..
and (Result[1] in Literals) then // it's one of the literals, then
and (Result[1] in Literals) then // it's one of the literals, then
Result:=Copy(Result, 2, Length(Result) - 2); //delete the 2 (but not others in it)
Result:=Copy(Result, 2, Length(Result) - 2); //delete the 2 (but not others in it)
While (WEnd<=Length(S)) and (S[Wend] in WhiteSpace) do
While (WEnd<=Length(S)) and (S[Wend] in WhiteSpace) do
function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string;var exitstatus:integer):integer;
function RunCommandIndir(const curdir:string;const exename:string;const commands:array of string;var outputstring:string;var exitstatus:integer):integer;