if RunCommand('/bin/bash',['-c','alias'],s, [poUsePipes, poWaitOnExit])
then writeln(s);
This does not work. The error is:
Error: Wrong number of parameters specified for call to "RunCommand"
Sorry for the delay, been out most of the day. It should not give you that error; it's a perfectly valid invocation of RunCommand(). I've just tested with this code:
resourcestring
sNotFound = 'Can''t find "%s"';
sCmdToRun = '%s %s';
sCmdError = 'Error: RunCommand() failed';
sResult = 'Result:' + LineEnding +
'%s' + LineEnding;
sNoResult = 'Result: Nothing to display.';
procedure TMainForm.btDoTestClick(Sender: TObject);
var
cmd: String = '';
cmdRes: String = '';
begin
cmd := FindDefaultExecutablePath('bash');
if cmd = '' then
ShowMessageFmt(sNotFound, ['bash'])
else begin
Memo.Text := Format(sCmdToRun, [cmd, '-c alias']);
if not RunCommand(cmd, ['-c', 'alias'], cmdRes, [poStderrToOutPut]) then
Memo.Lines.Add(sCmdError);
if cmdRes.IsEmpty then
Memo.Lines.Add(sNoResult)
else
Memo.Lines.Add(sResult, [cmdRes]);
end;
end;
and it compiles and runs without fault. See attached image.
As you can see invoking 'bash -c alias' in this machine also produces nothing so Marco seems to be right: aliases are not inherited by the child process. Bad luck!
To be clear: It's not that the command doesn't work, it's that there are no aliases so it outputs nothing.