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
|
|
|
<!-- Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. -->
|
|
|
|
<!-- SPDX-License-Identifier: curl -->
|
|
|
|
# VARIABLES
|
|
|
|
curl supports command line variables (added in 8.3.0). Set variables with
|
2024-02-07 01:07:07 +08:00
|
|
|
--variable name=content or --variable name@file (where `file` can be stdin if
|
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
|
|
|
set to a single dash (-)).
|
|
|
|
|
2024-02-07 01:07:07 +08:00
|
|
|
Variable contents can be expanded in option parameters using `{{name}}` if the
|
|
|
|
option name is prefixed with `--expand-`. This gets the contents of the
|
|
|
|
variable `name` inserted, or a blank if the name does not exist as a
|
|
|
|
variable. Insert `{{` verbatim in the string by prefixing it with a backslash,
|
|
|
|
like `\{{`.
|
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
|
|
|
|
|
|
|
You an access and expand environment variables by first importing them. You
|
|
|
|
can select to either require the environment variable to be set or you can
|
|
|
|
provide a default value in case it is not already set. Plain --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 it is not set, use
|
|
|
|
--variable %name=content or --variable %name@content.
|
|
|
|
|
|
|
|
Example. Get the USER environment variable into the URL, fail if USER is not
|
|
|
|
set:
|
|
|
|
|
|
|
|
--variable '%USER'
|
|
|
|
--expand-url = "https://example.com/api/{{USER}}/method"
|
|
|
|
|
|
|
|
When expanding variables, curl supports a set of functions that can make the
|
|
|
|
variable contents more convenient to use. It can trim leading and trailing
|
|
|
|
white space with *trim*, it can output the contents as a JSON quoted string
|
|
|
|
with *json*, URL encode the string with *url* or base64 encode it with
|
|
|
|
*b64*. You apply function to a variable expansion, add them colon separated to
|
|
|
|
the right side of the variable. Variable content holding null bytes that are
|
|
|
|
not encoded when expanded cause error.
|
|
|
|
|
|
|
|
Example: get the contents of a file called $HOME/.secret into a variable
|
|
|
|
called "fix". Make sure that the content is trimmed and percent-encoded sent
|
|
|
|
as POST data:
|
|
|
|
|
|
|
|
--variable %HOME
|
|
|
|
--expand-variable fix@{{HOME}}/.secret
|
|
|
|
--expand-data "{{fix:trim:url}}"
|
|
|
|
https://example.com/
|
|
|
|
|
|
|
|
Command line variables and expansions were added in in 8.3.0.
|