mirror of
https://github.com/nushell/nushell.git
synced 2024-11-07 17:14:23 +01:00
f6faf73e02
# Description Adds the `AddEnvVar` plugin call, which allows plugins to set environment variables in the caller's scope. This is the first engine call that mutates the caller's stack, and opens the door to more operations like this if needed. This also comes with an extra benefit: in doing this, I needed to refactor how context was handled, and I was able to avoid cloning `EngineInterface` / `Stack` / `Call` in most cases that plugin calls are used. They now only need to be cloned if the plugin call returns a stream. The performance increase is welcome (5.5x faster on `inc`!): ```nushell # Before > timeit { 1..100 | each { |i| $"2.0.($i)" | inc -p } } 405ms 941µs 952ns # After > timeit { 1..100 | each { |i| $"2.0.($i)" | inc -p } } 73ms 68µs 749ns ``` # User-Facing Changes - New engine call: `add_env_var()` - Performance enhancement for plugin calls # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting - [x] Document env manipulation in plugins guide - [x] Document `AddEnvVar` in plugin protocol |
||
---|---|---|
.. | ||
formats | ||
config.rs | ||
core_inc.rs | ||
custom_values.rs | ||
env.rs | ||
mod.rs | ||
register.rs | ||
stream.rs |