4 ms·
Well they could use an ordinary pipe, but they would have to group the later expression in parantheses. In bash the | creates a fork, so if you try: echo "sdfs
by terminalcommand 11y ago
Well they could use an ordinary pipe, but they would have to group the later expression in parantheses.
In bash the | creates a fork, so if you try:
echo "sdfsdf" | read sid && echo $sid
you get a blank line,
but if you try:
echo "sdfsdf" | (read sid && echo $sid)
you get "sdfsdf"
|& is an abbreviation for >2&1 | .
In zsh the grouping isn't needed, the expression works out of the box.
For more information on the subject:
http://stackoverflow.com/questions/13763942/bash-why-piping-input-to-read-only-works-when-fed-into-while-read-const http://stackoverflow.com/questions/13763942/bash-why-piping-...
- belovedeagle 11y agoHmm... looks like zsh runs the last element of the pipeline, if a builtin, in the current process. I use the pipe-to-read trick all the time in zsh without even thinking about it.