mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Process commands with single quotes (fixes #2862)
This commit is contained in:
parent
d03fa06aee
commit
837cc08394
2 changed files with 11 additions and 11 deletions
|
|
@ -30,7 +30,7 @@ unit uOSUtils;
|
|||
interface
|
||||
|
||||
uses
|
||||
SysUtils, Classes, LCLType, uDrive, DCBasicTypes, uFindEx
|
||||
SysUtils, Classes, Process, LCLType, uDrive, DCBasicTypes, uFindEx
|
||||
{$IF DEFINED(UNIX)}
|
||||
, DCFileAttributes
|
||||
{$IFDEF DARWIN}
|
||||
|
|
@ -149,9 +149,9 @@ function GetSfxExt: String;
|
|||
function IsAvailable(Drive: PDrive; TryMount: Boolean = True) : Boolean;
|
||||
function GetShell : String;
|
||||
{en
|
||||
Formats a string which will execute Command via shell.
|
||||
Formats parameters which will execute Command via shell.
|
||||
}
|
||||
function FormatShell(const Command: String): String;
|
||||
procedure FormatShell(Process: TProcess; const Command: String);
|
||||
{en
|
||||
Formats a string which will execute Command in a terminal.
|
||||
}
|
||||
|
|
@ -605,13 +605,13 @@ begin
|
|||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function FormatShell(const Command: String): String;
|
||||
procedure FormatShell(Process: TProcess; const Command: String);
|
||||
const
|
||||
EXEC_CMD = {$IF DEFINED(MSWINDOWS)}'/C'{$ELSE}'-c'{$ENDIF};
|
||||
begin
|
||||
{$IF DEFINED(UNIX)}
|
||||
Result := Format('%s -c %s', [GetShell, QuoteSingle(Command)]);
|
||||
{$ELSEIF DEFINED(MSWINDOWS)}
|
||||
Result := Format('%s /C %s', [GetShell, QuoteDouble(Command)]);
|
||||
{$ENDIF}
|
||||
Process.Executable:= GetShell;
|
||||
Process.Parameters.Add(EXEC_CMD);
|
||||
Process.Parameters.Add(Command);
|
||||
end;
|
||||
|
||||
procedure FormatTerminal(var sCmd: String; var sParams: String; bKeepTerminalOpen: tTerminalEndindMode);
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@ type
|
|||
sShellCmdLine := state.sSubParam + ' > ' + QuoteStr(sTmpFilename);
|
||||
Process := TProcessUTF8.Create(nil);
|
||||
try
|
||||
Process.CommandLine := FormatShell(sShellCmdLine);
|
||||
FormatShell(Process, sShellCmdLine);
|
||||
Process.Options := [poNoConsole, poWaitOnExit];
|
||||
Process.Execute;
|
||||
finally
|
||||
|
|
@ -958,7 +958,7 @@ begin
|
|||
sShellCmdLine := Copy(sParams, iStart, iCount) + ' > ' + QuoteStr(sTmpFile);
|
||||
Process := TProcessUTF8.Create(nil);
|
||||
try
|
||||
Process.CommandLine := FormatShell(sShellCmdLine);
|
||||
FormatShell(Process, sShellCmdLine);
|
||||
Process.CurrentDirectory := sWorkPath;
|
||||
Process.Options := [poWaitOnExit];
|
||||
Process.ShowWindow := swoHide;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue