4 ms·
I'd prefer they stop curl from detecting a pipe on STDOUT and assuming that the user must want download progress garbage. Why would I want it in a pipe any more
by vacri 9y ago
I'd prefer they stop curl from detecting a pipe on STDOUT and assuming that the user must want download progress garbage. Why would I want it in a pipe any more than I'd want it standalone? Inconsistent behaviour violates POLS.
- teddyh 9y agoThe GNU Coding Standards adresses this problem: “please don’t make the behavior of a command-line program depend on the type of output device it gets as standard output or standard input. […] There is an exception for programs whose output in certain cases is binary data. Sending such output to a terminal is useless and can cause trouble. If such a program normally sends its output to stdout, it should detect, in these cases, when the output is a terminal and give an error message instead. The -f option should override this exception, thus permitting the output to go to the terminal. ”¹ 1. https://www.gnu.org/prep/standards/standards.html#User-Interfaces https://www.gnu.org/prep/standards/standards.html#User-Inter...
- vacri 9y agoI don't know about the version of curl you use, but mine doesn't give download progress in binary format, and doesn't contain any content of the target you're curling. $ curl news.ycombinator.com > /dev/null % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 178 0 178 0 0 369 0 --:--:-- --:--:-- --:--:-- 370 You have to add an extra arg to get rid of that progress meter.
- joombaga 9y agoThe behavior doesn't exactly switch on pipe detection though. The progress bar consistently shows when outputting to a file. $ curl news.ycombinator.com -o /dev/null % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 178 0 178 0 0 948 0 --:--:-- --:--:-- --:--:-- 951 I mean, it's effectively doing tty detection, but I think it's fair to argue a semantic difference, and it's very similar to how ls strips colors and disables listing format when piped, which is mentioned by the next paragraph in the coding standards. Compatibility requires certain programs to depend on the type of output device. It would be disastrous if ls or sh did not do so in the way all users expect. In some of these cases, we supplement the program with a preferred alternate version that does not depend on the output device type. For example, we provide a dir program much like ls except that its default output format is always multi-column format.
- Aaron1011 9y agoIt's perfectly plausible that the user is piping it to a tool which can parse whatever binary format the file is using. Outputting it to the terminal, however, will just result in a mixture of unprintable characters and ANSI escape sequences.