{"id":6735,"date":"2014-11-17T10:11:12","date_gmt":"2014-11-17T09:11:12","guid":{"rendered":"http:\/\/daniel.haxx.se\/blog\/?p=6735"},"modified":"2024-11-17T17:00:37","modified_gmt":"2024-11-17T16:00:37","slug":"why-curl-defaults-to-stdout","status":"publish","type":"post","link":"https:\/\/daniel.haxx.se\/blog\/2014\/11\/17\/why-curl-defaults-to-stdout\/","title":{"rendered":"Why curl defaults to stdout"},"content":{"rendered":"\n<p><em>(Recap: I founded the curl project, I am still the lead developer and maintainer)<\/em><\/p>\n\n\n\n<p>When asking <a href=\"http:\/\/curl.haxx.se\/\">curl<\/a> to get a URL it&#8217;ll send the output to stdout by default. You can of course easily change this behavior with options or just using your shell&#8217;s redirect feature, but without any option it&#8217;ll spew it out to stdout. If you&#8217;re invoking the command line on a shell prompt you&#8217;ll immediately get to see the response as soon as it arrives.<\/p>\n\n\n\n<p>I decided curl should work like this, and it was a natural decision I made already when I worked on the predecessors during 1997 or so that later would turn into curl.<\/p>\n\n\n\n<p>On Unix systems there&#8217;s a common mantra that &#8220;everything is a file&#8221; but also in fact that &#8220;everything is a pipe&#8221;. You accomplish things on Unix by piping the output of one program into the input of another program. Of course I wanted curl to work as good as the other components and I wanted it to blend in with the rest. I wanted curl to feel like <a href=\"http:\/\/man7.org\/linux\/man-pages\/man1\/cat.1.html\">cat<\/a> but for a network resource. And cat is certainly not the only pre-curl command that writes to stdout by default; they are plentiful.<\/p>\n\n\n\n<p>And then: <strong>once I had made that decision and I released curl for the first time on March 20, 1998: the call was made. The default was set<\/strong>. I will not change a default and hurt millions of users. I rather continue to be questioned by newcomers, but now at least I can point to this blog post! \ud83d\ude42<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">About the wget rivalry<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignright\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"110\" src=\"http:\/\/daniel.haxx.se\/blog\/wp-content\/uploads\/2007\/09\/curl-keywords300.jpg\" alt=\"cURL\" class=\"wp-image-64\" title=\"cURL\"\/><\/figure>\n<\/div>\n\n\n<p>As I mention in my <a href=\"http:\/\/daniel.haxx.se\/docs\/curl-vs-wget.html\">curl vs wget<\/a> document, a very common comment to me about curl as compared to wget is that wget is &#8220;easier to use&#8221; because it needs no extra argument in order to download a single URL to a file on disk. I get that, if you type the full commands by hand you&#8217;ll use about three keys less to write &#8220;wget&#8221; instead of &#8220;curl -O&#8221;, but on the other hand if this is an operation you do often and you care so much about saving key presses I would suggest you make an alias anyway that is even shorter and then the amount of options for the command really doesn&#8217;t matter at all anymore.<\/p>\n\n\n\n<p>I put that argument in the same category as the people who argue that wget is easier to use because you can type it with your left hand only on a qwerty keyboard. Sure, that is indeed true but I read it more like someone trying to come up with a reason when in reality there&#8217;s actually another one underneath. Sometimes that other reason is a philosophical one about preferring GNU software (which curl isn&#8217;t) or one that is licensed under the GPL (which wget is) or simply that wget is what they&#8217;re used to and they know its options and recognize or like its progress meter better.<\/p>\n\n\n\n<p>I enjoy our friendly competition with wget and I seriously and honestly think it has made both our projects better and I like that users can throw arguments in our face like &#8220;but X can do Y&#8221;and X can alter between curl and wget depending on which camp you talk to. I also really like wget as a tool and I am the occasional user of it, just like most Unix users. I contribute to the wget project well, both with code and with general feedback. I consider myself a friend of the current wget maintainer as well as former ones.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>(Recap: I founded the curl project, I am still the lead developer and maintainer) When asking curl to get a URL it&#8217;ll send the output to stdout by default. You can of course easily change this behavior with options or just using your shell&#8217;s redirect feature, but without any option it&#8217;ll spew it out to &hellip; <a href=\"https:\/\/daniel.haxx.se\/blog\/2014\/11\/17\/why-curl-defaults-to-stdout\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Why curl defaults to stdout<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,6],"tags":[214,33,405,234],"class_list":["post-6735","post","type-post","status-publish","format-standard","hentry","category-curl","category-floss","tag-command-line","tag-curl-and-libcurl","tag-unix","tag-wget"],"_links":{"self":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/6735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/comments?post=6735"}],"version-history":[{"count":23,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/6735\/revisions"}],"predecessor-version":[{"id":26014,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/6735\/revisions\/26014"}],"wp:attachment":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/media?parent=6735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/categories?post=6735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/tags?post=6735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}