builtin_fn_env.d.elv 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #elvdoc:fn set-env
  2. #
  3. # ```elvish
  4. # set-env $name $value
  5. # ```
  6. #
  7. # Sets an environment variable to the given value. Calling `set-env VAR_NAME
  8. # value` is similar to `set E:VAR_NAME = value`, but allows the variable name
  9. # to be dynamic.
  10. #
  11. # Example:
  12. #
  13. # ```elvish-transcript
  14. # ~> set-env X foobar
  15. # ~> put $E:X
  16. # ▶ foobar
  17. # ```
  18. #
  19. # @cf get-env has-env unset-env
  20. #elvdoc:fn unset-env
  21. #
  22. # ```elvish
  23. # unset-env $name
  24. # ```
  25. #
  26. # Unset an environment variable. Calling `unset-env VAR_NAME` is similar to
  27. # `del E:VAR_NAME`, but allows the variable name to be dynamic.
  28. #
  29. # Example:
  30. #
  31. # ```elvish-transcript
  32. # ~> set E:X = foo
  33. # ~> unset-env X
  34. # ~> has-env X
  35. # ▶ $false
  36. # ~> put $E:X
  37. # ▶ ''
  38. # ```
  39. #
  40. # @cf has-env get-env set-env
  41. #elvdoc:fn has-env
  42. #
  43. # ```elvish
  44. # has-env $name
  45. # ```
  46. #
  47. # Test whether an environment variable exists. This command has no equivalent
  48. # operation using the `E:` namespace (but see https://b.elv.sh/1026).
  49. #
  50. # Examples:
  51. #
  52. # ```elvish-transcript
  53. # ~> has-env PATH
  54. # ▶ $true
  55. # ~> has-env NO_SUCH_ENV
  56. # ▶ $false
  57. # ```
  58. #
  59. # @cf get-env set-env unset-env
  60. #elvdoc:fn get-env
  61. #
  62. # ```elvish
  63. # get-env $name
  64. # ```
  65. #
  66. # Gets the value of an environment variable. Throws an exception if the
  67. # environment variable does not exist.
  68. #
  69. # Calling `get-env VAR_NAME` is similar to `put $E:VAR_NAME`, but allows the
  70. # variable name to be dynamic, and throws an exception instead of producing an
  71. # empty string for nonexistent environment variables.
  72. #
  73. # Examples:
  74. #
  75. # ```elvish-transcript
  76. # ~> get-env LANG
  77. # ▶ zh_CN.UTF-8
  78. # ~> get-env NO_SUCH_ENV
  79. # Exception: non-existent environment variable
  80. # [tty], line 1: get-env NO_SUCH_ENV
  81. # ```
  82. #
  83. # @cf has-env set-env unset-env