In Bash, an array preserves the arguments for a reusable curl invocation:

curl_options=(--noproxy '*' --fail --max-time 10)
curl "${curl_options[@]}" 'https://api.example/'

The single quotes protect the asterisk while the array is created. They are shell syntax, so the array stores one literal * character. The double-quoted array expansion then supplies each element as a separate argument.

Here --noproxy '*' asks curl to bypass proxies for every destination. Use the intended host list instead when only selected destinations should be direct.

A scalar containing text such as curl --noproxy '*' does not preserve the same structure. Quotes produced by expanding a variable are ordinary characters at that stage; Bash does not automatically parse them again as quoting syntax. A function is another suitable home for fixed options when it forwards its arguments with "$@".

Related articles