8000 Some characters like dash breaks commands / arguments highlighting · Issue #543 · google/zx · GitHub
[go: up one dir, main page]

Skip to content

Some characters like dash breaks commands / arguments highlighting #543

Open

Description

@zloirock

For example,

image

or

image

Activity

  1. antonmedv commented on Nov 3, 2022

    @antonmedv
    Collaborator

    Yes, my lexer is pretty basic here. Will try to improve.

  2. antonmedv commented on Nov 17, 2022

    @antonmedv
    Collaborator

    I really don’t want to bring whole bash parser/powershell parser into lib.

    Is there any other ideas on how to colorise output?

    maybe highlight only ${..} part and drop the rest?

  3. tamojit-123 commented on Apr 25, 2026

    @tamojit-123

    I really don’t want to bring whole bash parser/powershell parser into lib.

    Is there any other ideas on how to colorise output?

    maybe highlight only ${..} part and drop the rest?

    I’m with you on not pulling a full bash/PowerShell parser into zx just for log coloring. That feels like a lot of weight for something that should stay lightweight and best-effort.

    For this fix I kept the current heuristic approach and made it a bit less eager instead of making it smarter in a parser sense. The bug here was that we were treating + and : as syntax separators universally, which breaks perfectly normal tokens like test:unit, git+ssh://..., and similar argument values. So the change is just to stop classifying those characters as shell syntax and add regression coverage for those cases.

    I think that lands in a decent middle ground:

    no shell-specific parser
    no major behavior change
    fewer false positives in common real-world commands
    I’d personally keep highlighting for the command word, quotes,
    $..., and high-confidence operators like |, >, <, ;, &, =. Going all the way down to only ${...} would definitely be safer, but it also gives up a lot of the readability that makes verbose output nice to scan in the first place.

    So my thought is: keep it heuristic, but bias toward under-highlighting when we’re unsure. That seems like the best tradeoff for zx.

    PR : #1459

  4. AryanXCode646 commented on Sep 25, 2026

    @AryanXCode646

    I took a closer look at this and I think the underlying problem is worth treating as an argument-tokenization/quoting issue rather than as a special case for "-" itself.

    The important distinction seems to be between:

    • characters that are valid inside a single argument,
    • characters that have shell-level meaning,
    • and characters that should affect zx's command/argument highlighting or rendering.

    Ideally, zx should preserve the original argument boundaries and pass the resulting tokens to the shell without allowing characters such as "-" to change how an argument is classified or displayed.

    I’d suggest adding regression coverage around arguments containing:

    • leading/trailing "-";
    • "--flag=value";
    • paths containing "-";
    • multiple consecutive dashes;
    • quoted arguments containing "-";
    • arguments combining "-", spaces, and shell metacharacters.

    It would also be useful to assert both the generated command representation and the actual executed argument value. That would help distinguish a formatting/highlighting regression from an actual quoting or execution bug.

    If the current implementation is doing its own token/argument parsing for highlighting, centralizing that logic around the same argument representation used for execution could prevent the two paths from diverging.

    I’d be happy to put together a minimal regression test first, then use that to narrow down the smallest safe fix.

  5. abhikashbabu commented on Oct 27, 2026

    @abhikashbabu

    Hi @antonmedv, I would like to work on this issue.

    I can refine the command colorizing regex/lexer to ensure that dashes (-) inside flags (e.g. --flag=value), paths, and kebab-cased tokens are treated as part of the argument rather than splitting the syntax highlighting, without pulling in any heavy external parsers. I will also add regression test cases for dashes in arguments.

    Could you please assign this to me?

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0