curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Commands in configuration files vs flags

From: Brett Buddin via curl-users <>
Date: Sat, 3 Feb 2024 17:27:11 -0500

I recently started storing common requests in configuration files and
invoking them with “curl --config”. Those files reference a few
environment variables using the newer “variable” command. However, I
noticed the error severity of a missing environment variable differs
between “variable” as a configuration command and “--variable” as a
flag on the tool’s invocation.

When I use "variable" as a flag and the environment variable is
missing, the tool fails and no request is sent:

    ; curl --variable "%FOO"
    curl: Variable 'FOO' import fail, not set
    curl: option --variable: variable expansion failure
    curl: try 'curl --help' or 'curl --manual' for more information

This failure is consistent with the documentation.

When I use "variable" in a configuration file, I see a warning, but
the tool continues to execute the request:

    ; cat example.txt
    variable "%FOO"
    url ""
    ; curl --config example.txt
    curl: Variable 'FOO' import fail, not set
    Warning: example.txt:1: warning: 'variable' variable expansion
    Warning: failure

I found this a bit surprising, and it got me thinking: Are there any
configuration file commands that can cause a fatal error and stop the
execution of the request? Do all configuration file commands produce
warnings if you violate their expectations? I'm not sure if it exists
or is desirable, but is there a more strict mode for configuration
file error handling?
Received on 2024-02-04