curl command in git-bash
11:58 06 Jun 2018

I have a script written in bash and tested working in Linux (CentOS 7) and on MacOS. The script uses cURL to interact with a REST API compliant data platform (XNAT).

I was hoping that Windows users could use the same script within git-bash that comes packaged with Git for Windows. Unfortunately there seems to be an issue when using cURL in git-bash.

The first use I make of cURL is to retrieve a JSESSION cookie:

COOKIE=`curl -k -u $USERNAME https://theaddress/JSESSION`

On Linux, this asks the user for password and stores the cookie in COOKIE. In git-bash, issuing the command hangs, until using a "ctrl + C" to interrupt it. Strangely at that point the query message for the password is displayed, but too late, the script has terminated.

I have a suspicion that this may have to do with CR or LF issues, but cannot find some info I understand regarding this.

Any pointers would be welcome !

Thank you

EDIT: It appears the above command works fine if I pass the password in the command like this:

COOKIE=`curl -k -u $USERNAME:$PASSWORD https://theaddress/JSESSION`

However, as pointed here: Using cURL with a username and password? I would rather avoid having the user typing their password as a command argument.

So the question is now "why is cURL not prompting for a password when I use the first command?" when in git-bash on Windows, while that command behaves as expected in Linux or MacOS:

 COOKIE=`curl -k -u $USERNAME https://theaddress/JSESSION`
windows bash curl git-bash