I am working on Debian Stable Linux system with fpc version 3.0.0. On my system, the command 'alias' produces following output:
alias ll='ls -ltrk'
alias ls='ls --color=auto'
I also try to run it from following pascal file:
{$mode objfpc}
uses Process;
var s: ansistring;
begin
if RunCommand('alias', [], s)
then writeln(s);
end.
Though above file compiles and runs without any error, it produces no output.
Similarly, following also does not work:
if RunCommand('/bin/bash',['-c','alias'],s)
then writeln(s);
Following code, where I try to run an alias, also does not work:
if RunCommand('/bin/bash',['-c','ll'],s)
then writeln(s);
'll' is an alias on my system as shown above.
Following code from
https://wiki.freepascal.org/Executing_External_Programs#.28Process..29RunCommand works all right:
if RunCommand('/bin/bash',['-c','echo $PATH'],s)
then writeln(s);
Following summarizes my problem:
if RunCommand('/bin/bash',['-c','echo $PATH'],s) then writeln('res1:',s);
if RunCommand('/bin/bash',['-c','alias'],s) then writeln('res2:',s);
if RunCommand('/bin/bash',['-c','ll'],s) then writeln('res3:',s);
if RunCommand('echo $PATH', [], s) then writeln('res4:',s);
if RunCommand('alias', [], s) then writeln('res5:',s);
if RunCommand('ll', [], s) then writeln('res6:',s);
produces following output:
res1:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
res2:
First line gives correct output, 2nd line gives blank output; all others give no output.
Where is the problem and how can I run 'alias' and 'll' commands from pascal files?