nushell/crates
Douglas 72d50cf8b7
Convert Path to list in main and preserve case (#14764)
# Description

Fixes multiple issues related to `ENV_CONVERSION` and
path-conversion-to-list.

* #14681 removed some calls to `convert_env_values()`, but we found that
this caused `nu -n` to no longer convert the path properly.
* `ENV_CONVERSIONS` have apparently never preserved case, meaning a
conversion with a key of `foo` would not update `$env.FOO` but rather
create a new environment variable with a different case.
* There was a partial code-path that attempted to solve this for `PATH`,
but it only worked for `PATH` and `Path`.
* `convert_env_values()`, which handled `ENV_CONVERSIONS` was called in
multiple places in the startup depending on flags.

This PR:

* Refactors the startup to handle the conversion in `main()` rather than
in each potential startup path
* Updates `get_env_var_insensitive()` functions added in #14390 to
return the name of the environment variable with its original case. This
allows code that updates environment variables to preserve the case.
* Makes use of the updated function in `ENV_CONVERSIONS` to preserve the
case of any updated environment variables. The `ENV_CONVERSION` key
itself is still case **insensitive**.
* Makes use of the updated function to preserve the case of the `PATH`
environment variable (normally handled separately, regardless of whether
or not there was an `ENV_CONVERSION` for it).

## Before

`env_convert_values` was run:

* Before the user `env.nu` ran, which included `nu -c <commandstring>`
and `nu <script.nu>`
* Before the REPL loaded, which included `nu -n`

## After

`env_convert_values` always runs once in `main()` before any config file
is processed or the REPL is started

# User-Facing Changes

Bug fixes

# Tests + Formatting

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

Added additional tests to prevent future regression.

# After Submitting

There is additional cleanup that should probably be done in
`convert_env_values()`. This function previously handled
`ENV_CONVERSIONS`, but there is no longer any need for this since
`convert_env_vars()` runs whenever `$env.ENV_CONVERSIONS` changes now.

This means that the only relevant task in the old `convert_env_values()`
is to convert the `PATH` to a list, and ensure that it is a list of
strings. It's still calling the `from_string` conversion on every
variable (just once) even though there are no `ENV_CONVERSIONS` at this
point.

Leaving that to another PR though, while we get the core issue fixed
with this one.
2025-01-10 10:18:44 -06:00
..
nu-cli Convert Path to list in main and preserve case (#14764) 2025-01-10 10:18:44 -06:00
nu-cmd-base Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-cmd-extra Add run-time type checking for command pipeline input (#14741) 2025-01-08 23:09:47 +01:00
nu-cmd-lang Enable conditional source and use patterns by allowing null as a no-op module (#14773) 2025-01-09 06:37:27 -06:00
nu-cmd-plugin Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-color-config Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-command Add flag to debug profile to output duration field as Value::Duration (#14749) 2025-01-09 17:09:16 -06:00
nu-derive-value Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-engine Convert Path to list in main and preserve case (#14764) 2025-01-10 10:18:44 -06:00
nu-explore fix(explore): handle zero-size cursor in binary viewer (#14592) 2025-01-07 12:10:25 -06:00
nu-glob Create nu_glob::is_glob function (#14717) 2025-01-01 19:04:17 -05:00
nu-json Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-lsp feat(lsp): document_symbols and workspace_symbols (#14770) 2025-01-09 07:19:32 -06:00
nu-parser Enable conditional source and use patterns by allowing null as a no-op module (#14773) 2025-01-09 06:37:27 -06:00
nu-path Don't expand ndots if prefixed with ./ (#14755) 2025-01-05 17:07:34 -05:00
nu-plugin Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-plugin-core Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-plugin-engine Convert Path to list in main and preserve case (#14764) 2025-01-10 10:18:44 -06:00
nu-plugin-protocol Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-plugin-test-support Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-pretty-hex Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-protocol Convert Path to list in main and preserve case (#14764) 2025-01-10 10:18:44 -06:00
nu-std Add run-time type checking for command pipeline input (#14741) 2025-01-08 23:09:47 +01:00
nu-system Replace std::time::Instant with web_time::Instant (#14668) 2024-12-25 16:50:02 +08:00
nu-table [WIP] Try to fix tabled panic (#14710) 2025-01-01 08:09:23 -06:00
nu-term-grid Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-test-support Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu-utils Add auto option for config.use_ansi_coloring (#14647) 2024-12-26 11:00:01 -06:00
nu_plugin_custom_values Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu_plugin_example Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu_plugin_formats Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu_plugin_gstat Bump git2 from 0.19.0 to 0.20.0 (#14776) 2025-01-08 13:53:02 +00:00
nu_plugin_inc Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu_plugin_nu_example Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu_plugin_polars Add run-time type checking for command pipeline input (#14741) 2025-01-08 23:09:47 +01:00
nu_plugin_python Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu_plugin_query Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nu_plugin_stress_internals Bump version to 0.101.1 (#14661) 2024-12-24 23:47:00 +01:00
nuon fix nuon conversions of range values (#14687) 2025-01-07 21:29:39 +01:00
README.md Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.