Skip to content

Backtick strings cannot contain non-whitespace characters followed by = (?!) #6853

Closed

Description

@webbedspace

Describe the bug

It seems that adding = to certain backtick strings causes them to no longer be parsed correctly. I pored over a few commits related to backtick strings, but I still don't understand what the heck is up with this.

How to reproduce

C:\Coding\nushell.github.io〉`=`
Error: nu::parser::unknown_command (link)

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

C:\Coding\nushell.github.io〉`a=`
Error: nu::parser::unknown_command (link)

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

C:\Coding\nushell.github.io〉` =`
 =
C:\Coding\nushell.github.io〉`\=`
Error: nu::parser::unknown_command (link)

  × Unknown command.
   ╭─[entry #309:1:1]
 1 │ `\=`
   · ──┬─
   ·   ╰── unknown command
   ╰────

Expected behavior

Why do backtick strings have this strange exception? To me, they should just work as alternatives to single-quote strings.

Screenshots

No response

Configuration

key value
version 0.70.0
branch
commit_hash 9ef65dc
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.64.0 (a55dd71d5 2022-09-19)
rust_channel stable-x86_64-pc-windows-msvc
cargo_version cargo 1.64.0 (387270bc7 2022-09-16)
pkg_version 0.70.0
build_time 2022-10-18 18:55:02 +00:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins

Additional context

No response

Activity

  1. added
    A:parser
    on Oct 22, 2022
  2. rgwood commented on Oct 23, 2022

    @rgwood
    Contributor

    This is a weird one. I spent 10 min digging into it but couldn't find an obvious cause. Most likely a bug in the parser, which has several special cases for '=' characters.

  3. merelymyself commented on Oct 23, 2022

    @merelymyself
    Contributor

    Maybe relevant: #6401

  4. rgwood commented on Oct 23, 2022

    @rgwood
    Contributor

    Also likely relevant: #5806

  5. kaathewisegit commented on Nov 21, 2023

    @kaathewisegit
    Contributor

    The reason for this issue is the ENV=value command syntax. Nushell interprets ["=a"] as $env '["' = 'a"]'. Thus, things like ["=a"] printenv work, while a=b gives the same error.

  6. kronberger-droid commented on Nov 13, 2026

    @kronberger-droid
    Contributor

    Fixed by #14053.
    Backtick strings containing = work as arguments, list items and record values now.
    At the start of a line a backtick word is treated as a command name, so that case tries to run it, which i think is by design.

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

    A:parser

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions