传递一个带括号的URL来卷曲

如果我尝试传递包含括号的卷曲URL,则会失败并显示错误消息:

$ curl 'http://www.google.com/?TEST[]=1'
curl: (3) [globbing] illegal character in range specification at pos 29

但是,如果我从两个括号中逃脱,它似乎工作:

$ curl 'http://www.google.com/?TEST[]=1'

有趣的是,我使用反斜杠来只转义第一个支架,它以错误代码20497静静地失败:

$ curl 'http://www.google.com/?TEST[]=1'
$ echo $!
20497

我的问题是如何解决这个一般情况? 是否有一个参数会自动跳过网址,或者在传递卷曲之前需要转义的字符的描述?


没关系,我在文档中找到它:

-g/--globoff
              This  option  switches  off  the "URL globbing parser". When you set this option, you can
              specify URLs that contain the letters {}[] without having them being interpreted by  curl
              itself.  Note  that  these  letters  are not normal legal URL contents but they should be
              encoded according to the URI standard.
链接地址: http://www.djcxy.com/p/1327.html

上一篇: Passing a URL with brackets to curl

下一篇: CouchDB cURL Windows Command Line Invalid JSON