1 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 2 SPDX-License-Identifier: curl 3 Long: variable 4 Arg: <[%]name=text/@file> 5 Help: Set variable 6 Category: curl 7 Example: --variable name=smith $URL 8 Added: 8.3.0 9 See-also: config 10 Multi: append 11 --- 12 Set a variable with "name=content" or "name@file" (where "file" can be stdin 13 if set to a single dash (-)). The name is a case sensitive identifier that 14 must consist of no other letters than a-z, A-Z, 0-9 or underscore. The 15 specified content is then associated with this identifier. 16 17 Setting the same variable name again overwrites the old contents with the new. 18 19 The contents of a variable can be referenced in a later command line option 20 when that option name is prefixed with "--expand-", and the name is used as 21 "{{name}}" (without the quotes). 22 23 --variable can import environment variables into the name space. Opt to either 24 require the environment variable to be set or provide a default value for the 25 variable in case it is not already set. 26 27 --variable %name imports the variable called 'name' but exits with an error if 28 that environment variable is not already set. To provide a default value if 29 the environment variable is not set, use --variable %name=content or 30 --variable %name@content. Note that on some systems - but not all - 31 environment variables are case insensitive. 32 33 When expanding variables, curl supports a set of functions that can make the 34 variable contents more convenient to use. You apply a function to a variable 35 expansion by adding a colon and then list the desired functions in a 36 comma-separated list that is evaluated in a left-to-right order. Variable 37 content holding null bytes that are not encoded when expanded, causes an 38 error. 39 40 Available functions: 41 .RS 42 .TP 15 43 **trim** 44 removes all leading and trailing white space. 45 .TP 46 **json** 47 outputs the content using JSON string quoting rules. 48 .TP 49 **url** 50 shows the content URL (percent) encoded. 51 .TP 52 **b64** 53 expands the variable base64 encoded 54 .RE 55 .IP 56