Skip to content

Comment on Show HN: Quickly copy a file between computersparent

Comments

Your examples are all expected to sort out whether to accept an input stream or start an output stream, but without an explicit command, which poses a problem -- the app would have to determine that the input stream is empty before switching modes to streaming output. That's not so easy -- suppose the operator unintentionally pipes an empty input file? Will the app know what to do?

Most (I won't say all) command-line apps must be explicitly told which mode to use. There's a good reason.

isatty() to the rescue, but that's not to say that there shouldn't be a -- option or defaulting to a different mode depending on argv[0], like gzip does.

[0] http://pubs.opengroup.org/onlinepubs/007904875/functions/isa...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.