Re:Curl Command Line Variables
by nerdponx on Monday July 31, 2023 @06:44AM
(#36940808)
I wonder what the use case for this is, when every shell already offers parameter expansion of some kind. Is it so that you can write Curl command lines that work in any shell identically, once properly quoted?
[ Parent
| on HN ]
The blog post states the feature got implemented because a user wanted to use environment variables for values in configuration file variables.
I missed that, thanks.
You can tell curl to read its arguments from a file, in which case a shell won't get to interpret them first, perhaps this feature is aimed at that?
Looks like there are a couple of use cases.
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.