Commands in configuration files vs flags

Brett Buddin via curl-users <[email protected]>
Newsgroups gmane.comp.web.curl.general
Message-ID <CALpBNfM3VnK1U+4P+kURDuOv7ZVqONEJ4rNEXJu6QnMdz=nQmA@mail.gmail.com>
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" https://httpbin.org/anything
    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 "https://httpbin.org/anything"
    ; 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?
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.