Skip to content

[bug] --color=never is not respected #1850

@MagicDuck

Description

@MagicDuck

Please read the FAQ for the bug you encountered.

  • I have read the existing FAQ

⏯ Playground Link

https//not-applicable-to-this-issue

💻 Code

It might be a regression, but even with the latest release, sg does not seem to respect --color=never.

sg run --pattern 'garbage rule$A$B' --lang typescript --color=never

I am seeing this problem because the neovim plugin I maintain (https://github.com/MagicDuck/grug-far.nvim) needs to call astgrep with --color=never.

🙁 Actual behavior

Notice the colors in the output

Image

If I redirect stderr to a file and edit it with nvim, I see the color codes:

�[31mError:�[0m �[1mCannot parse query as a valid pattern.�[0m
�[34mHelp:�[0m The pattern either fails to parse or contains error. Please refer to pattern syntax guide.
�[1;2mSee also:�[0m �]8;;https://ast-grep.github.io/guide/pattern-syntax.html�\�[3;36mhttps://ast-grep.github.io/guide/pattern-syntax.html�[0m�]8;;�\

�[31m✖�[0m Caused by
�[31m╰▻�[0m Multiple AST nodes are detected. Please check the pattern source `garbage rule$A$B`.

🙂 Expected behavior

no colors

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions