1*6236dae4SAndroid Build Coastguard Worker--- 2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al. 3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl 4*6236dae4SAndroid Build Coastguard WorkerLong: variable 5*6236dae4SAndroid Build Coastguard WorkerArg: <[%]name=text/@file> 6*6236dae4SAndroid Build Coastguard WorkerHelp: Set variable 7*6236dae4SAndroid Build Coastguard WorkerCategory: curl 8*6236dae4SAndroid Build Coastguard WorkerAdded: 8.3.0 9*6236dae4SAndroid Build Coastguard WorkerMulti: append 10*6236dae4SAndroid Build Coastguard WorkerSee-also: 11*6236dae4SAndroid Build Coastguard Worker - config 12*6236dae4SAndroid Build Coastguard WorkerExample: 13*6236dae4SAndroid Build Coastguard Worker - --variable name=smith --expand-url "$URL/{{name}}" 14*6236dae4SAndroid Build Coastguard Worker--- 15*6236dae4SAndroid Build Coastguard Worker 16*6236dae4SAndroid Build Coastguard Worker# `--variable` 17*6236dae4SAndroid Build Coastguard Worker 18*6236dae4SAndroid Build Coastguard WorkerSet a variable with `name=content` or `name@file` (where `file` can be stdin 19*6236dae4SAndroid Build Coastguard Workerif set to a single dash (`-`)). The name is a case sensitive identifier that 20*6236dae4SAndroid Build Coastguard Workermust consist of no other letters than a-z, A-Z, 0-9 or underscore. The 21*6236dae4SAndroid Build Coastguard Workerspecified content is then associated with this identifier. 22*6236dae4SAndroid Build Coastguard Worker 23*6236dae4SAndroid Build Coastguard WorkerSetting the same variable name again overwrites the old contents with the new. 24*6236dae4SAndroid Build Coastguard Worker 25*6236dae4SAndroid Build Coastguard WorkerThe contents of a variable can be referenced in a later command line option 26*6236dae4SAndroid Build Coastguard Workerwhen that option name is prefixed with `--expand-`, and the name is used as 27*6236dae4SAndroid Build Coastguard Worker`{{name}}`. 28*6236dae4SAndroid Build Coastguard Worker 29*6236dae4SAndroid Build Coastguard Worker--variable can import environment variables into the name space. Opt to either 30*6236dae4SAndroid Build Coastguard Workerrequire the environment variable to be set or provide a default value for the 31*6236dae4SAndroid Build Coastguard Workervariable in case it is not already set. 32*6236dae4SAndroid Build Coastguard Worker 33*6236dae4SAndroid Build Coastguard Worker--variable %name imports the variable called `name` but exits with an error if 34*6236dae4SAndroid Build Coastguard Workerthat environment variable is not already set. To provide a default value if 35*6236dae4SAndroid Build Coastguard Workerthe environment variable is not set, use --variable %name=content or 36*6236dae4SAndroid Build Coastguard Worker--variable %name@content. Note that on some systems - but not all - 37*6236dae4SAndroid Build Coastguard Workerenvironment variables are case insensitive. 38*6236dae4SAndroid Build Coastguard Worker 39*6236dae4SAndroid Build Coastguard WorkerWhen expanding variables, curl supports a set of functions that can make the 40*6236dae4SAndroid Build Coastguard Workervariable contents more convenient to use. You apply a function to a variable 41*6236dae4SAndroid Build Coastguard Workerexpansion by adding a colon and then list the desired functions in a 42*6236dae4SAndroid Build Coastguard Workercomma-separated list that is evaluated in a left-to-right order. Variable 43*6236dae4SAndroid Build Coastguard Workercontent holding null bytes that are not encoded when expanded, causes an 44*6236dae4SAndroid Build Coastguard Workererror. 45*6236dae4SAndroid Build Coastguard Worker 46*6236dae4SAndroid Build Coastguard WorkerAvailable functions: 47*6236dae4SAndroid Build Coastguard Worker 48*6236dae4SAndroid Build Coastguard Worker## trim 49*6236dae4SAndroid Build Coastguard Workerremoves all leading and trailing white space. 50*6236dae4SAndroid Build Coastguard Worker 51*6236dae4SAndroid Build Coastguard Worker## json 52*6236dae4SAndroid Build Coastguard Workeroutputs the content using JSON string quoting rules. 53*6236dae4SAndroid Build Coastguard Worker 54*6236dae4SAndroid Build Coastguard Worker## url 55*6236dae4SAndroid Build Coastguard Workershows the content URL (percent) encoded. 56*6236dae4SAndroid Build Coastguard Worker 57*6236dae4SAndroid Build Coastguard Worker## b64 58*6236dae4SAndroid Build Coastguard Workerexpands the variable base64 encoded 59