docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
---
|
2023-07-31 17:50:28 +08:00
|
|
|
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
|
|
|
|
Added: 8.3.0
|
|
|
|
Multi: append
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
See-also:
|
|
|
|
- config
|
|
|
|
Example:
|
2024-07-08 02:31:20 +08:00
|
|
|
- --variable name=smith --expand-url "$URL/{{name}}"
|
2023-07-31 17:50:28 +08:00
|
|
|
---
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
|
|
|
|
# `--variable`
|
|
|
|
|
2024-02-07 01:07:07 +08:00
|
|
|
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
|
2023-07-31 17:50:28 +08:00
|
|
|
must consist of no other letters than a-z, A-Z, 0-9 or underscore. The
|
|
|
|
specified content is then associated with this identifier.
|
|
|
|
|
2023-09-08 20:32:29 +08:00
|
|
|
Setting the same variable name again overwrites the old contents with the new.
|
2023-07-31 17:50:28 +08:00
|
|
|
|
|
|
|
The contents of a variable can be referenced in a later command line option
|
2024-02-07 01:07:07 +08:00
|
|
|
when that option name is prefixed with `--expand-`, and the name is used as
|
|
|
|
`{{name}}`.
|
2023-07-31 17:50:28 +08:00
|
|
|
|
|
|
|
--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.
|
|
|
|
|
2024-02-07 01:07:07 +08:00
|
|
|
--variable %name imports the variable called `name` but exits with an error if
|
2023-08-01 20:11:50 +08:00
|
|
|
that environment variable is not already set. To provide a default value if
|
2023-07-31 17:50:28 +08:00
|
|
|
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
|
2023-08-01 20:11:50 +08:00
|
|
|
comma-separated list that is evaluated in a left-to-right order. Variable
|
2023-09-08 20:32:29 +08:00
|
|
|
content holding null bytes that are not encoded when expanded, causes an
|
2023-07-31 17:50:28 +08:00
|
|
|
error.
|
|
|
|
|
2023-08-09 16:37:18 +08:00
|
|
|
Available functions:
|
2024-01-09 17:36:14 +08:00
|
|
|
|
|
|
|
## trim
|
2023-08-09 16:37:18 +08:00
|
|
|
removes all leading and trailing white space.
|
2024-01-09 17:36:14 +08:00
|
|
|
|
|
|
|
## json
|
2023-08-09 16:37:18 +08:00
|
|
|
outputs the content using JSON string quoting rules.
|
2024-01-09 17:36:14 +08:00
|
|
|
|
|
|
|
## url
|
2023-08-09 16:37:18 +08:00
|
|
|
shows the content URL (percent) encoded.
|
2024-01-09 17:36:14 +08:00
|
|
|
|
|
|
|
## b64
|
2023-08-09 16:37:18 +08:00
|
|
|
expands the variable base64 encoded
|