This program, an implementation of the tee command, first available in 1974, takes in standard input and for each file specified either appends or wri

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2024-10-09 13:30:02

This program, an implementation of the tee command, first available in 1974, takes in standard input and for each file specified either appends or writes to each file until the standard input is done. As it does so it passes out what is read to standard output.

The tee command is a handy way, and one of the only ways to branch standard input to save to one or more files and to reproduce standard input as standard output for consumers down the line. Additionally, to allow for the avoidance of redirecting standard output to /dev/null, the -S option allows for the avoidance of carry-over of standard input to standard output. This is not something I have seen on any other implementations.

The official tee waits for stdin even when nothing has been sent to it. I've added support for waiting on keyboard input for string data. Control-C works to exit this. So although this is reading input as a string, this is likely not harmful. The main stdin reader reads in bytes and thus can handle cat test.jpg | gotee -S out.jpg.

The argument parsing library used here does not deal with arguments such as -1, -2, -, etc. It may be that an argument will need to have a different identifier to work around this.

Leave a Comment