Implementation of various pipes #11
Replies: 2 comments 11 replies
-
ProposalDetails of how pipes will be implemented in codePiped commands will be executed parallelly, and the stdout of the source command will be set to a buffer, and the same buffer will be set as the stdin of the destination command. // grep -r "todo: " . | do stuff
var buf bytes.Buffer
// grep -r "todo: " .
grep := exec.Command("grep", "-r", "todo: ", ".")
grep.Stdin = os.Stdin
grep.Stdout = buf
grep.Stderr = buf
// do stuff
do := exec.Command("do", "stuff")
do.Stdin = buf
do.Stdout = os.Stdout
do.Stderr = os.Stderr
grep.Start()
do.Start() Settling on a proper syntax for piping
|
Beta Was this translation helpful? Give feedback.
-
Ok, this seem to be the same discussions point I had raised when I was reviewing the PR earlier which related to the order of operations. I remember that you wanted to do this using Now, just to clarify a few things: You want to run the pipes in parallel by default? From my understanding, pipes can never really be parallelised since they by definition depend on the output or one command as input for the other command. Syntax is a question of taste - its your program, you can design it however you want. However, I think it is better to rely on symbols rather than letters (makes it easy to lex properly) Writing + appending to files shouldn't have a command in my opinion. The reason being that when we will be running processes (commands) in mash, we will have full control over the streams (in/out/err) which means that you should be able to write the them without the presence of a command as long as the symbols are distinct. ( About storing output as variables, what do you mean exactly? Do you mean something like the following? SOMETHING=`ls -l` That already stores the values properly and I had mentioned this before that the command vs not command route would have problems with variables since you have the If you want to store the output and exit code into a variable, I think a custom type |
Beta Was this translation helpful? Give feedback.
-
This discussion is for deciding on how to implement pipes in mash. Here are the topics for discussion:
stdout
and\orstderr
.Beta Was this translation helpful? Give feedback.
All reactions