3 ms·
"Surely I was not the first to write the following two higher-order programs..." He's right. There is, for example, rc (the Plan 9 shell, made in 1989). The
by gnosis 17y ago
"Surely I was not the first to write the following two higher-order programs..."
He's right. There is, for example, rc (the Plan 9 shell, made in 1989).
The following is from section 10, "Pipeline branching" of: http://plan9.bell-labs.com/sys/doc/rc.html http://plan9.bell-labs.com/sys/doc/rc.html
"< or > followed by a command in braces causes the command to be run with its standard output or input attached to a pipe. The parent command (cmp in the example) is started with the other end of the pipe attached to some file descriptor or other, and with an argument that will connect to the pipe when opened (e.g., /dev/fd/6)."
- cgs1019 17y agoI believe the rc feature exemplified in the link is actually equivalent to that used in the this bash idiom: $ cmp <(old) <(new) (only the braces differ). The author of the article describes a case in which the command in question (unlike cmp) cannot read its input from a pipe such as this, namely xdvi. So for instance $ cat file.dvi | xdvi or $ xdvi <(file.dvi) would not work due to the nature of xdvi, but one could use $ cat file.dvi | tmp xdvi as a shorthand for $ cat file.dvi > /tmp/blah $ xdvi /tmp/blah $ rm /tmp/blah (of course using cat this way would be stupid, but suppose that the file data is going to stdout via a command such as curl, as in the article, and it becomes non-trivial). I really like the characterization of these commands as sort of second-order and I like the 2 new ones offered here (although I try not to get too addicted to command line features that aren't going to be around when I'm hopping from server to server).