1
The following command works in GNU Bash on FreeBSD but not in Git Bash on Windows:
curl -X PUT https://example.com/_config/cors/origins -d '"*"'
The intended result is to send a PUT request to https://example.com/_config/cors/origins with the body "*" (including the quotes - it's a JSON string).
However on Windows, the asterisk gets expanded as a glob even though it’s within quotes. Excerpt from --trace-ascii cURL log:
0000: PUT /_config/cors/origins HTTP/1.1 004f: User-Agent: curl/7.30.0 008e: Content-Length: 13 00a2: Content-Type: application/x-www-form-urlencoded 00d3: => Send data, 13 bytes (0xd) 0000: .editorconfig == Info: upload completely sent off: 13 out of 13 bytes
(.editorconfig is the first file in the current directory.)
Escaping with a backslash ('"\*"') transmits the backslash:
0000: PUT /_config/cors/origins HTTP/1.1 004f: User-Agent: curl/7.30.0 008e: Content-Length: 4 00a1: Content-Type: application/x-www-form-urlencoded 00d2: => Send data, 4 bytes (0x4) 0000: "\*" == Info: upload completely sent off: 4 out of 4 bytes
Two backslashes also transmits both backslashes in the request.
0000: PUT /_config/cors/origins HTTP/1.1 004f: User-Agent: curl/7.30.0 008e: Content-Length: 5 00a1: Content-Type: application/x-www-form-urlencoded 00d2: => Send data, 5 bytes (0x5) 0000: "\\*" == Info: upload completely sent off: 5 out of 5 bytes
Is this a bug?
I posted an answer but when you say, you used two backslashes can you actually edit your post to show us an example? Or perhaps just edit to show all the different ideas/attempts you made? That would be helpful from a debugging standpoint. – JakeGould – 2015-04-03T21:19:59.613
Are you sure bash is the culprit and not curl? What curl are you using (native build or cygwin/msys one)? Some versions of libc for Windows will expand * (but not other globs) while parsing the command line (from
GetCommandLineto argc/argv) -> can you test with cmd.exe (that passes the command line unchanged) if you can also see the "globbing"? – mihi – 2015-04-04T10:41:10.023When using a
cmdprompt I can get it to work by passing-d \"*\"– Tamlyn – 2015-04-04T12:31:41.537and when you try
-d '\"*\"'in bash, it does not work? – mihi – 2015-04-04T12:50:17.117nope, it sends the backslashes too. – Tamlyn – 2015-04-06T15:30:01.567