Skip to content

Allow case-sensitive environment variable setting #17778

@lunagl

Description

@lunagl

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions