括弧付きのURLをcurlに渡す 質問する

括弧付きのURLをcurlに渡す 質問する

括弧を含む URL を curl に渡そうとすると、エラーが発生して失敗します。

$ 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'

これを修正するにはどうすればいいでしょうか? URL を自動的にエスケープする引数、または curl に渡す前にエスケープする必要がある文字の説明はありますか?

ベストアンサー1

-gコマンドに追加:

-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 curl itself interpret them.
      Note that these letters are not normal legal URL contents but they should be encoded
      according to the URI standard.

      Example:
       curl -g "https://example.com/{[]}}}}"

curl.se/docs/manpage.html#-g

おすすめ記事