brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: curl -q as the first option ignores your .curlrc

Curl
~/tips/tip-curl-q-ignore-curlrc

curl -q -fsS https://example.com/api/status

Make a script behave the same on every machine, whatever the local curl config says.

A ~/.curlrc is great for your own typing, but it also changes every curl call in scripts. -q tells curl to skip it.

The catch is that it only works as the very first argument:

curl -q -fsS https://example.com/api/status
curl -fsS -q https://example.com/api/status

The first line ignores the config file. In the second, -q comes too late: curl has already read .curlrc, and the option does nothing useful.

Why bother? Common lines in a .curlrc are location, silent, a proxy, a user agent or insecure. Each of them can change what a script does. A script that works on your laptop because your config follows redirects may break on a server without that config. Worse, an insecure line you once added for a test would turn off certificate checks in every script that runs as your user.

I’d put -q at the start of curl calls in shared scripts, and then spell out every option the script needs. It only skips the default config file; a file you pass with -K is still read. Environment variables such as https_proxy are not part of the config file, so they still apply.

Further reading: curl man page, everything curl: config file

More Curl tips curl --trace-ascii – https://example.com/ Retry-After: 120 curl -fsS --fail-early \ url = "https://example.com/data/latest.json" curl -4 -s -o /dev/null -w '%{remote_ip} %{http_code}\n' https://example.com/ All Curl tips (71) All topics

Link