execute bash?

Puming via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 8 03:08:07 PDT 2016


Hi,

I'd like to write an interactive commmand line tool for my 
commands, and that also support bash commands.

My first thinking is 'why not just execute those bash commands 
with bash'? But it turns out to have some problem.

When I use executeShell, I found that .bashrc is not loaded so 
that custom aliases like 'll' are not usable, and there is no 
color in the output.

Then I use spawnProcess:

```
import std.process;
void main() {
   for (int i = 0; i < 3; ++i) { // emulate the interactive loop
     string cmd = "ll";
     wait(spwanProcess(["/bin/bash", "-i", "-c", cmd]));
   }
}
```

with the bash option "-i", the .bashrc is loaded and the output 
is colored, but with each command loop, the program is stopped 
(equal to Ctrl-Z).

I thought the subprocess may have returned some special char like 
Ctrl-Z, so I changed to use pipeProcess to try to catch them. But 
it does not work either.

My question is:

1. what can I do to prevent this stop effect?
2. what is the best way to make a proxy to a bash process?


More information about the Digitalmars-d-learn mailing list