Skip to content

Better error message if env var is used as var - #9522

Merged
sophiajt merged 1 commit into
nushell:mainfrom
sophiajt:env_var_not_var
Jun 25, 2023
Merged

sophiajt merged 1 commit into
nushell:mainfrom
sophiajt:env_var_not_var

Conversation

@sophiajt

@sophiajt sophiajt commented Jun 25, 2023 •

Copy link
Copy Markdown
Contributor

Description

This PR improves the error message if an environment variable (that's visible before the parser begins) is used in the form of $PATH instead of $env.PATH.

Before:

Error: nu::parser::variable_not_found

  × Variable not found.
   ╭─[entry #31:1:1]
 1 │ echo $PATH
   ·      ──┬──
   ·        ╰── variable not found.
   ╰────

After:

Error: nu::parser::env_var_not_var

  × Use $env.PATH instead of $PATH.
   ╭─[entry #1:1:1]
 1 │ echo $PATH
   ·      ──┬──
   ·        ╰── use $env.PATH instead of $PATH
   ╰────

User-Facing Changes

Just the improvement to the error message

Tests + Formatting

After Submitting

@amtoine amtoine left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loving this 👌

@sophiajt
sophiajt merged commit 33535c5 into nushell:main Jun 25, 2023
@sophiajt
sophiajt deleted the env_var_not_var branch June 25, 2023 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants