4 ms·
I'm not familiar with the usage of "pipeline" in this context. Could a kind soul elaborate? These look like boolean operators to me.
by Riverheart 7y ago
I'm not familiar with the usage of "pipeline" in this context. Could a kind soul elaborate? These look like boolean operators to me.
- unlinked_dll 7y agoComes from unix. You "pipe" the output of one program to the input of another. In unix shell scripts it's common to use `|` symbol for this in shells. It's just a different paradigm of composing scripts that can be quite natural. Chaining means you run one command followed by the other, so "&&" could be read as "and then"
- Riverheart 7y agoRight but Powershell has '|' for piping objects between commands. What does || do that the current operator doesn't support or is it just another way of saying -or? Edit: nvm, I see below these are emulating the behaviour expected from bash. I guess it's called the pipeline operator because it uses the pipe symbol rather than doing any piping.
- rjmholt 7y agoIn my RFC I dubbed them (&& and ||) the pipeline chain operators because you use them to chain syntactic pipelines together conditionally. The POSIX shell spec calls them AND-OR lists, which I didn’t think was as descriptive. To explain the pipeline idea a bit better, there are two ways of seeing a pipeline (in PowerShell or in a POSIX shell). One is at runtime; a command executes, taking its input from an input and spitting it out to an output. Chain a few commands together hooking the output of one to the input of another and you have a pipeline. (In POSIX shells of course these in/out locations are file descriptors, whereas in PowerShell they’re memory locations.) But also a pipeline can refer to the syntax of a pipeline; something like `ls | grep “* .txt”` is a pipeline in terms of the POSIX shell grammar. Similarly in PowerShell, `gci | ? Name -like “* .txt”` is a pipeline syntax. And since you can chain these pipelines together with && and ||, I called the operators “pipeline chain operators”. BTW, if you ever want to look at the abstract syntax tree of a PowerShell command, it’s very easy to do by wrapping it in a scriptblock and grabbing its AST: $ast = { gi file.txt && rm file.txt }.Ast $ast.EndBlock.Statements[0]
- Riverheart 7y agoInteresting. Thanks for the detailed response!
- chubot 7y agoYeah the title is wrong -- it's not a pipeline. | is a pipe while || is "or".