equal
deleted
inserted
replaced
76 |
76 |
77 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
77 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
78 |
78 |
79 try { |
79 try { |
80 if (isatty(fileno(stdin))) { |
80 if (isatty(fileno(stdin))) { |
|
81 /** |
|
82 * Our program is executed on TTY without input stream redirection → read from default file location. |
|
83 * e.g. $ relpipe-in-fstab | … |
|
84 * (we don't expect that user is writing the content of fstab by hand on the terminal) |
|
85 */ |
81 ifstream s("/etc/fstab"); |
86 ifstream s("/etc/fstab"); |
82 processDataStream(cout, &s); |
87 processDataStream(cout, &s); |
83 } else { |
88 } else { |
|
89 /** |
|
90 * Input stream comes from a file or is piped from other command → read it instead of default file. |
|
91 * e.g. $ cat /etc/fstab | grep '/mnt/' | relpipe-in-fstab | … |
|
92 * or $ relpipe-in-fstab < /etc/fstab | … # without UUoC |
|
93 * or $ ssh example.com cat /etc/fstab | relpipe-in-fstab | … |
|
94 * or $ cat | relpipe-in-fstab | … # user writes the fstab content by hand |
|
95 */ |
84 processDataStream(cout, &cin); |
96 processDataStream(cout, &cin); |
85 } |
97 } |
86 resultCode = CLI::EXIT_CODE_SUCCESS; |
98 resultCode = CLI::EXIT_CODE_SUCCESS; |
87 |
99 |
88 } catch (RelpipeWriterException e) { |
100 } catch (RelpipeWriterException e) { |