Hacker News new | past | comments | ask | show | jobs | submit login

thank you :)



Is there any good reason not to use an ordinary pipe there? In zsh, strace blah |& read sid


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-...


Hmm... 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.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: