8000 Bracket pairing breaks comments · Issue #8022 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

Bracket pairing breaks comments #8022

@kopischke

Description

@kopischke

Running fish version 3.2.2-325-g7123e2f25 (built from HEAD via Homebrew) on macOS 11.3.1 in the stock Terminal.app. I tried fish without third-party customisations by executing sh -c 'env HOME=$(mktemp -d) fish' and checked whether it affected the behaviour I am reporting (it did not).


This seems related to #7970 and, unlike that issue, does not seem to be covered by #2485: fish’s somewhat eccentric bracket pairing triggers across comment boundaries, effectively breaking comments. I submit for your consideration the following code:

echo f[oo # not valid, no matching ]

To my best understanding, the argument to that echo command is f[oo, followed by a “not valid, no matching ]” comment, and executing that snippet should trigger the “unexpected end of string” error, as there is an unmatched opening bracket that is not in first word character position. Note GitHub’s fish syntax highlighting concurs with my interpretation, for what that is worth. However.

What fish actually does is to treat this as a valid f[oo # not valid, no matching ] argument, which it executes without complaining. I find this utterly baffling, as there is no paired bracket syntax construct outside variable indexing that justifies this.

The current behaviour can’t be right, can it?

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

      0