Skip to content

Write-PSFHostColor does not work with certain characters #721

@woldaker

Description

@woldaker

Tested in PowerShell 7.5.4 using Windows Terminal.

If any of the following characters appear in any colored section ('<c="red">here</c>') the coloring will not work for that section. It appears not to affect other sections of the same string.

\ ? * + [ $ ^ ( )

I tried escaping them with backslashes. Did not work.
I tried escaping them with backticks. Did not work.
I tried HTML codes such as &#63; for a question mark. Did not block the coloring but did not convert to ? either.
I tried doubling them up. This works for single-quotes only within a single-quoted string, as far as I can tell. It does not work for any of the characters I listed.

Sometimes, an error message will pop up:

Image

It makes sense that those characters would cause issues. It looks from the error messages to be related to regular expressions in some way.

Note: I was going to paste a different screenshot of the other cases I mentioned but for some reason it doesn't show. It just duplicates the first screenshot. Anyway, the same thing happens whether you do '<c="red">...</c>' or "<c='red'>...</c>".

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions