Curl Command Line Variables
daniel.haxx.se
daniel.haxx.se
Would it not have been both simpler and more powerful to have a .curlrcscript file that gets executed and the output used as the config contents?
Even the original use case looks somewhat fishy: the user has secrets in their environment, but they can't have a bash script or function wrapper around curl to call curl with the environment variable baked? Again, more general and powerful than a limited variable-replacement scheme using yet-another curl-specific syntax.
I can think of many examples where the direction curl went will backfire: people will want variable based on other variables. People will want variable based on conditions (if/else), etc. All things a general scripting solution would fulfill in a standard way.
For me, the big value-add is the filter functions - for example, proper JSON escaping or URL encoding is hard to do with pure sh, usually needing some external tool; now that it’s built into curl, it will simplify scripts and reduce the list of dependencies.
Environment variables are nice for this. Locally scoped and reasonably secure.
[1]: https://hurl.dev
The expansion supports several transformations that can help build values:
"json" outputs the content using JSON string quoting rules.
"url" shows the content URL (percent) encoded.
"b64" expands the variable base64 encoded
Command-line arguments are visible to others (eg, through ps or /proc/<pid>/cmdline) so including a secret directly on the command-line may leak data.(For context, here's a SO message asking how to avoid that sort of leakage: https://stackoverflow.com/questions/3830823/hiding-secret-fr... )
You can use different files for different configurations, rather than depend on (global) shell variables.
`--expand-data “{ \"homedir\": \"{{HOME:json}}\” "`
To disable.