nushell / nushell/nushell

Allow case-sensitive environment variable setting

Open
#17,778 14 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

category:enhancement status:needs-triage
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 14h
Merged PRs (30d)
79

Description

Basics
  • I have done a basic search through the issue tracker to find similar or related issues.
  • I have made myself familiar with the available features of Nushell for the particular area this enhancement request touches.
Related problem

Nushell treats all environment variables as case-sensitive, and has #17558 made this more consistent on all platforms.
Unfortunately, as #14551 correctly notes, this goes against the Unix convention and POSIX (https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap08.html).

As also noted in that issue, this becomes particularly problematic when multiple variables that only differ in casing are present. Personally, it caused me a decent amount of headache just now to figure out why $env.SHELL is suddenly modified when loading a Nix devShell using direnv.

Describe the solution you'd like

It would therefore be great to have a way of defining/assigning env vars in a case-respecting manner. That means at minimum not coercing an assignment to shell into an assignment to the existing variable SHELL, and ideally allowing two variables that only differ in casing (such as SHELL and shell) to coexist.

It might be implemented in the form of a special flag for load-env and similar commands.

Describe alternatives you've considered

Ideally, I would love to be able to turn off case-insensitivity entirely, since I see little benefit (beyond Windows compatibility, which is not relevant for my use case) and believe it only causes more issues and annoying edge cases.

But as Nushell seems to have committed to case insensitivity I assume such a toggle would be difficult to realize and would probably cause a bunch of incompatibility between scripts etc.

Additional context and details

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Nushell's environment-variable assignment and loading behavior, especially the paths used by load-env and related commands. Define how case-respecting assignment and coexistence of differently cased variables should work, then add coverage for the selected behavior and verify it on the relevant platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, shell
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.