News for hackers. Stuff that matters.
Re:Why curl defaults to stdout by jrochkind1 on Monday November 17, 2014 @08:48AM (#8618162)
I actually want printing to stdout more often than I want printing to file, it is more often what I need. I guess different people have different use cases.

I will admit that rather than learn the right command to have curl print to file -- when I _do_ want to write to file, I do use wget (and appreciate it's default progress bar; there's probably some way to make curl do that too, but I've never learned it either).

When I want writing to stdout, I reach for curl, which is most of the time. (Also for pretty much any bash script use, I use curl; even if I want write to a file in a bash script, I just use `>` or lookup the curl arg).

It does seem odd that I use two different tools, with mostly entirely different and incompatible option flags -- rather than just learning the flags to make curl write to a file and/or to make wget write to stdout. I can't entirely explain it, but I know I'm not alone in using both, and choosing from the toolbox based on some of their default behaviors even though with the right args they can probably both do all the same things. Heck, in the OP the curl author says they use wget too -- now I'm curious if it's for something that the author knows curl doesn't do, or just something the author knows wget will do more easily!

To me, they're like different tools focused on different use cases, and I usually have a feel for which is the right one for the job. Although it's kind of subtle, and some of my 'feel' may be just habit or superstition! But as an example, recently I needed to download a page and all it's referenced assets (kind of like browsers will do with a GUI; something I only very rarely have needed to do), and I thought "I bet wget has a way to do this easily", and looked at the man page and it did, and I have no idea if curl can do that too but I reached for wget and was not disappointed.

Re:Why curl defaults to stdout by mikepurvis on Monday November 17, 2014 @09:11AM (#8618233)
I think the biggest nuisance with this strategy is that neither tool is included by default on the machines I'm usually working with— wget is missing from my Mac, and curl is missing from my Ubuntu servers.

Both can be quickly rectified, but it's still a pretty big pain.

Re:Why curl defaults to stdout by js2 on Monday November 17, 2014 @10:59AM (#8618734)
The obvious solution is to submit a patch to curl, such that when it's called as "wget", it emulates wget's command-line options, and vice versa.

Witten only partially in jest. I've submitted patches to both projects and both are relatively straight-forward code bases to dive in to.

Re:Why curl defaults to stdout by ams6110 on Monday November 17, 2014 @09:42AM (#8618351)
Yes, the stdout default is great for working with/testing REST APIs on the command line, for example.
Re:Why curl defaults to stdout by craigching on Monday November 17, 2014 @01:31PM (#8619622)
Indeed, I have never considered using wget at all with my REST APIs. In fact, the only time I do use wget is when I want to directly download a url to a file on the command line, but if I'm writing a script, I use curl.
Re:Why curl defaults to stdout by shadytrees on Tuesday November 18, 2014 @01:02AM (#8622598)
I myself have an alias to get wget-like behavior (still not as verbose, but great for downloading binaries): alias w='curl -#O'

I'm afraid I side with the left-handedness argument. Years of muscle memory make me want to type "w".

Re:Why curl defaults to stdout by hobarrera on Wednesday November 19, 2014 @09:02AM (#8630020)
To save to a file it's just

curl -O https://example.com/file.txt

It'll save to file.txt.

Re:Why curl defaults to stdout by nanoscopic on Monday November 17, 2014 @11:02AM (#8618748)
"to have curl print to file -- when I _do_ want to write to a file"

You have it reversed. Wget will output to the screen/pipe if you output to the "file" --. Curl does not. "curl http://www.google.com/index.html -o --" does not output to the screen. It creates a file named "--".

Re:Why curl defaults to stdout by slucidi on Monday November 17, 2014 @12:14PM (#8619151)
To clarify, I think the parent was using -- as a poor-man's emdash in this case.
Re:Why curl defaults to stdout by jrochkind1 on Monday November 17, 2014 @12:55PM (#8619381)
yes, that was just an emdash not meant to be command line syntax. Sorry for the confusion.
Re:Why curl defaults to stdout by ainiriand on Tuesday November 18, 2014 @06:52AM (#8623502)
And don't forget all the options available for TLS certificates that are available with cURL!