Passing a URL with brackets to curl

后端 未结 2 2013
时光取名叫无心
时光取名叫无心 2020-12-04 07:46

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 charac         


        
相关标签:
2条回答
  • 2020-12-04 08:19

    Globbing uses brackets, hence the need to escape them with a slash \. Alternatively, the following command-line switch will disable globbing:

    --globoff (or the short-option version: -g)

    Ex:

    curl --globoff https://www.google.com?test[]=1
    
    0 讨论(0)
  • 2020-12-04 08:26

    Never mind, I found it in the docs:

    -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.
    
    0 讨论(0)
提交回复
热议问题