3 ms·
I studied the line read _ _ sid < <(2>&1 strace -esetsid setsid sh -c "exec $PROGRAM <> /dev/tty2 >&0 2>&1 ") <( is an example of process substitution, in ca
by terminalcommand 11y ago
I studied the line
read _ _ sid < <(2>&1 strace -esetsid setsid sh -c "exec $PROGRAM <> /dev/tty2 >&0 2>&1 ")
<( is an example of process substitution, in case anyone is interested. Basically it feeds the stdout of the subshell into the stdin of the read (previous) command.
Here is a detailed explanation:
http://www.tldp.org/LDP/abs/html/abs-guide.html#PROCESS-SUB http://www.tldp.org/LDP/abs/html/abs-guide.html#PROCESS-SUB
- CatCookie 11y agothank you :)
- belovedeagle 11y agoIs there any good reason not to use an ordinary pipe there? In zsh, strace blah |& read sid
- terminalcommand 11y agoWell 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.