If I try to pass a URL to curl that contains brackets, it fails with an error:
$ curl 'http://www.google.com/?TEST[]=1'
curl: (3) [globbing] illegal character in range specification at pos 29
However, if I escape both brackets, it appears to work:
$ curl 'http://www.google.com/?TEST\[\]=1'
Interestingly, I use a backslash to escape only the first bracket it fails silently with error code 20497:
$ curl 'http://www.google.com/?TEST\[]=1'
$ echo $!
20497
My question is how to fix this for general cases? Is there an argument that will escape URLs automatically, or a description of the characters that need to be escaped before passing to curl?