News for hackers. Stuff that matters.
Re:Curl doesn’t spew binary anymore by vacri on Saturday June 17, 2017 @12:32PM (#14576540)
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.
Re:Curl doesn’t spew binary anymore by teddyh on Saturday June 17, 2017 @12:55PM (#14576633)
The 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-Inter...

Re:Curl doesn’t spew binary anymore by vacri on Saturday June 17, 2017 @07:13PM (#14578144)
I 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.
Re:Curl doesn’t spew binary anymore by joombaga on Saturday June 17, 2017 @07:40PM (#14578217)
The 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.

Re:Curl doesn’t spew binary anymore by Aaron1011 on Saturday June 17, 2017 @03:37PM (#14577379)
It'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.