On 12/26/2012 09:18 PM, Aaron Davies wrote:
afaict from my general *nx experience, the basic rule for text-handling utilities (filters, etc.) is as follows: first, no argument(s) means stdin is used; second, argument(s) means stdin is ignored, unless "-" is present as an argument, in which case stdin is used in the position in the sequence where the first "-" occurs (later "-"s have no effect, presumably due to the way pipes behave); finally, if no arguments and not receiving a pipe and in some sort of interactive context (stdin is a tty?), stdin is accepted from the terminal (and handled line-by-line (rev(1)) or at end-of-file (tac(1)), as appropriate).
That's the usual operation of a filter yes. Though there are always exceptions like dd for example. Note multiple '-' aren't usually ignored. cat - - - seq 10 | paste - - - ...
cat(1) is the canonical example. my questions are: have i described the behavior correctly, and is there anything (in any context--C, shell, etc.) to make creating new tools which follow these rules easier?
I don't know of higher level abstractions for this behavior. thanks, Pádraig.
