curl/docs/cmdline-opts/variable.d
Viktor Szakats ce3dce9015
tidy-up: mostly whitespace nits
- delete completed TODO from `./CMakeLists.txt`.
- convert a C++ comment to C89 in `./CMake/CurlTests.c`.
- delete duplicate EOLs from EOF.
- add missing EOL at EOF.
- delete whitespace at EOL (except from expected test results).
- convert tabs to spaces.
- convert CRLF EOLs to LF in GHA yaml.
- text casing fixes in `./CMakeLists.txt`.
- fix a codespell typo in `packages/OS400/initscript.sh`.

Closes #11772
2023-08-31 23:02:10 +00:00

57 lines
1.9 KiB
D

c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Long: variable
Arg: <[%]name=text/@file>
Help: Set variable
Category: curl
Example: --variable name=smith $URL
Added: 8.3.0
See-also: config
Multi: append
---
Set a variable with "name=content" or "name@file" (where "file" can be stdin
if set to a single dash (-)). The name is a case sensitive identifier that
must consist of no other letters than a-z, A-Z, 0-9 or underscore. The
specified content is then associated with this identifier.
Setting the same variable name again will overwrite the old contents with the
new.
The contents of a variable can be referenced in a later command line option
when that option name is prefixed with "--expand-", and the name is used as
"{{name}}" (without the quotes).
--variable can import environment variables into the name space. Opt to either
require the environment variable to be set or provide a default value for the
variable in case it is not already set.
--variable %name imports the variable called 'name' but exits with an error if
that environment variable is not already set. To provide a default value if
the environment variable is not set, use --variable %name=content or
--variable %name@content. Note that on some systems - but not all -
environment variables are case insensitive.
When expanding variables, curl supports a set of functions that can make the
variable contents more convenient to use. You apply a function to a variable
expansion by adding a colon and then list the desired functions in a
comma-separated list that is evaluated in a left-to-right order. Variable
content holding null bytes that are not encoded when expanded, will cause
error.
Available functions:
.RS
.TP 15
**trim**
removes all leading and trailing white space.
.TP
**json**
outputs the content using JSON string quoting rules.
.TP
**url**
shows the content URL (percent) encoded.
.TP
**b64**
expands the variable base64 encoded
.RE
.IP