variable.d 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. The name must be unique within a command line invoke, setting the same
  17. variable name again will be ignored.
  18. The contents of a variable can be referenced in a later command line option
  19. when that option name is prefixed with "--expand-", and the name is used as
  20. "{{name}}" (without the quotes).
  21. --variable can import environment variables into the name space. Opt to either
  22. require the environment variable to be set or provide a default value for the
  23. variable in case it is not already set.
  24. --variable %name imports the variable called 'name' but exits with an error if
  25. that environment variable is not already set. To provide a default value if
  26. the environment variable is not set, use --variable %name=content or
  27. --variable %name@content. Note that on some systems - but not all -
  28. environment variables are case insensitive.
  29. When expanding variables, curl supports a set of functions that can make the
  30. variable contents more convenient to use. You apply a function to a variable
  31. expansion by adding a colon and then list the desired functions in a
  32. comma-separated list that is evaluated in a left-to-right order. Variable
  33. content holding null bytes that are not encoded when expanded, will cause
  34. error.
  35. These are functions that can help you get the value inserted more
  36. conveniently.
  37. "trim" removes all leading and trailing white space.
  38. "json" outputs the content using JSON string quoting rules.
  39. "url" shows the content URL (percent) encoded.
  40. "b64" expands the variable base64 encoded