# HG changeset patch # User František Kučera # Date 1534067163 -7200 # Node ID e8be873f1eabeacda24fa05ef502957dd3461f15 # Parent 6615824d69b7fa1df469f5fa8823209d2bfa3216 fstab: documentation for isatty(fileno(stdin)) diff -r 6615824d69b7 -r e8be873f1eab relpipe-in-fstab.cpp --- a/relpipe-in-fstab.cpp Sat Aug 11 22:58:00 2018 +0200 +++ b/relpipe-in-fstab.cpp Sun Aug 12 11:46:03 2018 +0200 @@ -78,9 +78,21 @@ try { if (isatty(fileno(stdin))) { + /** + * Our program is executed on TTY without input stream redirection → read from default file location. + * e.g. $ relpipe-in-fstab | … + * (we don't expect that user is writing the content of fstab by hand on the terminal) + */ ifstream s("/etc/fstab"); processDataStream(cout, &s); } else { + /** + * Input stream comes from a file or is piped from other command → read it instead of default file. + * e.g. $ cat /etc/fstab | grep '/mnt/' | relpipe-in-fstab | … + * or $ relpipe-in-fstab < /etc/fstab | … # without UUoC + * or $ ssh example.com cat /etc/fstab | relpipe-in-fstab | … + * or $ cat | relpipe-in-fstab | … # user writes the fstab content by hand + */ processDataStream(cout, &cin); } resultCode = CLI::EXIT_CODE_SUCCESS;