Skip to content

fix unknown_command when parsing certain strings with equal signs#14053

Merged
fdncred merged 1 commit intonushell:mainfrom
sgvictorino:parse-strings-with-equals
Oct 11, 2024
Merged

fix unknown_command when parsing certain strings with equal signs#14053
fdncred merged 1 commit intonushell:mainfrom
sgvictorino:parse-strings-with-equals

Conversation

@sgvictorino
Copy link
Copy Markdown
Contributor

@sgvictorino sgvictorino commented Oct 10, 2024

Description

Prevents errors when = is used before the end of:

  • strings in lists/records (with a symbol adjacent to the quotes)
  • raw strings
> ["=a"]
Error: nu::parser::unknown_command

  × Unknown command.
   ╭─[entry #9:1:1]
 1 │ ["=a"]
   · ───┬──
   ·    ╰── unknown command
   ╰────
> r#'=a'#
Error: nu::parser::unknown_command

  × Unknown command.
   ╭─[entry #5:1:1]
 1 │ r#'=a'#
   · ───┬───
   ·    ╰── unknown command
   ╰────

Closes #13902, closes #13901, closes #9879, closes #6401, closes #5806

User-Facing Changes

Variable names in environment shorthand assignments must satisfy is_identifier.

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Oct 10, 2024

wow, thanks! this closes a good amount of issues. although, i'm not sure it closes #6853 since that still fails with this pr with unknow command, but maybe it's supposed to? there's also some examples that don't work in #9879 but i think that's right too. but the rest seem great.

I wonder if you'd be up to adding more tests, specifically ones from #9879 ? Some that work and some that don't work so we can be sure we don't regress.

@sgvictorino
Copy link
Copy Markdown
Contributor Author

Thanks, I removed #6853 from the description. I believe that already works as intended because backtick strings aren't supposed to contain non-quote symbols.

In the #9879 examples there are some duplicate columns. Did you see any other errors?

Let me know if the new tests are alright!

# Description

Prevents errors when `=` is used in:

- strings in lists/records with a symbol adjacent to the quotes
- raw strings

```
> ["=a"]
Error: nu::parser::unknown_command

  × Unknown command.
   ╭─[entry #9:1:1]
 1 │ ["=a"]
   · ───┬──
   ·    ╰── unknown command
   ╰────
```

```
> r#'=a'#
Error: nu::parser::unknown_command

  × Unknown command.
   ╭─[entry #5:1:1]
 1 │ r#'=a'#
   · ───┬───
   ·    ╰── unknown command
   ╰────
```

# User-Facing Changes

Variable names in env shorthand assignments must satisfy
`is_identifier`.
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Oct 11, 2024

Thanks!

@fdncred fdncred merged commit df0a174 into nushell:main Oct 11, 2024
@hustcer hustcer added this to the v0.99.0 milestone Oct 11, 2024
@sgvictorino sgvictorino deleted the parse-strings-with-equals branch October 11, 2024 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants