variable.d 1.9 KB

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