Skip to content

Unset environment variable after temporary assignment #1448

@hanche

Description

@hanche
Contributor

After temporary assignment to an environment variable, that variable should be unset after the function exit, provided it was unset before. Consider this (using the new tmp syntax):

⬥ date; has-env TZ; { tmp E:TZ = UTC; date }; date; has-env TZ; put $E:TZ
Sat Dec 11 10:07:40 CET 2021
⮕ $false
Sat Dec 11 09:07:40 UTC 2021
Sat Dec 11 09:07:40 UTC 2021
⮕ $true
⮕ ''

As can be seen from the various date outputs, it does make a difference whether an environment variable is unset or merely empty.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅Done

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @hanche

      Issue actions

        Unset environment variable after temporary assignment · Issue #1448 · elves/elvish