fstab: documentation for isatty(fileno(stdin)) v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 12 Aug 2018 11:46:03 +0200
branchv_0
changeset 3 e8be873f1eab
parent 2 6615824d69b7
child 4 0afc596749a1
fstab: documentation for isatty(fileno(stdin))
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;