Open GoogleCodeExporter opened 9 years ago
Supporting piping itself is pretty straightforward: if stdin is a tty, then
handle the shell argument values; if stdin is not a tty, then handle the piped
content instead.
Original comment by mathias@qiwi.be
on 29 Apr 2013 at 11:58
This would be very nice to be able to pipe to zopfli!
It's worth noting that instead of looking at the stdin every time it's also common to accept a special "-" file name which acts as a placeholder for stdin or stdout (depending on the context). Now this isn't perfect (special file names are never good) and it's probably better to have a separate parameter but it goes to show that trying to determine whether the stdin is a tty isn't necessary (and might come with its own downsides).
BTW, a third party solution exists at http://stackoverflow.com/q/38353692/2261442
@Herst That code writes the streams to temporary files, which isn't really a solution.
I really prefer using the "-c" flag, like gzip and xz. If it were based on "detecting whether stdin is a tty", that would lead to inconsistent behavior if you try to run a script in the background in certain ways, invoke it from a GUI, etc.
Original issue reported on code.google.com by
mathias@qiwi.be
on 29 Apr 2013 at 11:56