D: How do I pipe (|) through three programs using std.process?
BoQsc
vaidas.boqsc at gmail.com
Sat Nov 18 18:09:53 UTC 2023
Latest iteration on this thread.
Limitations:
* pipes through two programs.
* very verbose, hard to use.
```
import std;
import std.process;
version (Windows) { enum Find = "find"; }
version (Posix) { enum Find = "grep"; }
void pipeTo(Pipe p, string nextprogram){
spawnShell(nextprogram, p.readEnd, stdout);
}
auto program(string name){
Pipe p = std.process.pipe;
spawnShell(name, stdin, p.writeEnd);
return p;
}
void main()
{
program("echo HelloWorld").pipeTo(nextprogram: Find ~ `
"HelloWorld"`);
}
```
More information about the Digitalmars-d-learn
mailing list