0

Assume I have a working http-server running on example.com:8080

On ubuntu, this command

$curl http://example.com:8080/

gives

<h1>hello</h1>

while git-bash on windows gives extra connection info

enter image description here

How do I get the simpler output, like the one on ubuntu? In other words, is it feasible to mute the extra connection info for git-bash on windows?

2
  • What does which curl report – are you using the curl.exe that came with Windows, or the one that came with Git-Bash? Commented Mar 9, 2022 at 5:53
  • Not an answer to your question but WSL would give you 100% compat and this problem would not exist. Commented Mar 9, 2022 at 6:54

2 Answers 2

1

According to my man curl, -q doesn't do what you think it does:

       -q, --disable
              If used as the first parameter on the command line, 
              the curlrc config file will not be read and used. 
              See the -K, --config for details on the default 
              config file search path.

You probably want to use option -s:

       -s, --silent
              Silent or quiet mode. Don't show progress meter or error messages.
              Makes Curl mute. It will still output the data you ask for, 
              potentially even to the terminal/stdout unless you redirect it.

              Use -S, --show-error in addition to this option to disable 
              progress meter but still show error messages.
0

This is regular curl status output, only showing up in an unexpected situation. You would normally see this kind of progress bar when redirecting curl's output to a file (or something else besides a terminal), and in those cases you would need the -s option to suppress it.

Now the progress bar should not show up when curl is already outputting to a terminal – the problem here is that due to the way "terminals" work in Windows (and especially when MSYS' MinTTY gets involved), curl might actually not understand what it is writing to.

git-bash uses the MSYS toolkit to emulate certain Unix features – it looks like you're using the MinTTY terminal, which does various things in order to emulate Unix style "pseudo-terminal" functionality on top of Windows' native console input/output, which has traditionally worked very differently from Unix tty – for a very long time Windows simply did not have anything even remotely like Unix tty devices, so in order to achieve Unix-like "stream" behavior, MinTTY most likely had to use pipes instead.

So it is very likely that only programs specifically built for MSYS will recognize MinTTY as a "terminal" (i.e. be able to understand its emulation), whereas native Win32 programs such as the Windows built-in curl.exe will instead see the output being attached to a pipe, just as if curl was being used in a pipeline, and this causes it to activate the progress bar display.

It shouldn't appear if you use the MSYS version of curl.exe, but otherwise use -s to turn it off by force.

1
  • My impression (and it's not the first time) is you have lot of knowledge. Still I'm not eager to upvote answers like this one. The answer gives insight and makes sense, but how do I know this insight is really true? Maybe you're guessing. It would be better if you linked to documentation, articles or anything that supports your statements. I don't know the way "terminals" work in Windows. IDK these various things MinTTY does. IDK how native console I/O has traditionally worked. In cases when I know what you know, or when I can test, I can tell you are almost always right. Here I cannot. Commented Mar 9, 2022 at 20:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .