--- 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;