Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Console] Fix color support check on non-Windows platforms #52940

Merged
merged 1 commit into from Dec 8, 2023

Conversation

theofidry
Copy link
Contributor

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #45917
License MIT

Currently checking the color support based on ANSICON, ConEmuANSI=ON or TERM=xTerm is done only for Widows. I could not find any reason as to why and it does not make much sense as it is. Especially if we consider that TERM=xTerm is a term check and we do another one (not Widows specific) which is TERM_PROGRAM=Hyper.

This potentially fixes #45917.

This also looks more in line with the intent (based on the title) of #27831 and #27794.

@carsonbot
Copy link

Hey!

To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done?

Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review.

Cheers!

Carsonbot

@carsonbot carsonbot changed the title fix: Correctly check color support [Console] fix: Correctly check color support Dec 8, 2023
@OskarStark
Copy link
Contributor

The referenced issue mentioned 5.4, should this PR target 5.4 too?

@OskarStark OskarStark changed the title [Console] fix: Correctly check color support [Console] Correctly check color support Dec 8, 2023
@OskarStark OskarStark added the Bug label Dec 8, 2023
@theofidry
Copy link
Contributor Author

The referenced issue mentioned 5.4, should this PR target 5.4 too?

Ah indeed, my bad I forgot 5.4 is still supported.

@theofidry
Copy link
Contributor Author

Waiting on #52941 and #52942.

@carsonbot carsonbot closed this Dec 8, 2023
@theofidry
Copy link
Contributor Author

Yo @carsonbot not cool

@xabbuh xabbuh reopened this Dec 8, 2023
@xabbuh xabbuh marked this pull request as ready for review December 8, 2023 11:14
@xabbuh xabbuh requested a review from chalasr as a code owner December 8, 2023 11:14
@carsonbot carsonbot added this to the 6.4 milestone Dec 8, 2023
@theofidry
Copy link
Contributor Author

thanks @xabbuh ❤️

fabpot added a commit that referenced this pull request Dec 8, 2023
This PR was merged into the 5.4 branch.

Discussion
----------

Refactor hyper check location

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        | None
| License       | MIT

Extracted from #52940 to reduce the noise of that PR. There is no logic change, only a potentially a performance (I assume non-existent given it's a if check of a constant). If it is a concern however, this could be checked _before_ the windows specific checks.

Commits
-------

9c09e16 refactor: hyper check
@theofidry theofidry changed the base branch from 6.4 to 5.4 December 8, 2023 13:33
@theofidry theofidry changed the title [Console] Correctly check color support [Console] Fix color support check on non-Windows platforms Dec 8, 2023
@fabpot fabpot modified the milestones: 6.4, 5.4 Dec 8, 2023
@fabpot
Copy link
Member

fabpot commented Dec 8, 2023

Thank you @theofidry.

@fabpot fabpot merged commit 7121397 into symfony:5.4 Dec 8, 2023
0 of 2 checks passed
@theofidry theofidry deleted the fix/color-support branch December 8, 2023 14:51
renovate bot added a commit to Lendable/composer-license-checker that referenced this pull request Jan 2, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [symfony/console](https://symfony.com)
([source](https://togithub.com/symfony/console)) | `6.4.1` -> `6.4.2` |
[![age](https://developer.mend.io/api/mc/badges/age/packagist/symfony%2fconsole/6.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/symfony%2fconsole/6.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/symfony%2fconsole/6.4.1/6.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/symfony%2fconsole/6.4.1/6.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [symfony/process](https://symfony.com)
([source](https://togithub.com/symfony/process)) | `6.4.0` -> `6.4.2` |
[![age](https://developer.mend.io/api/mc/badges/age/packagist/symfony%2fprocess/6.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/symfony%2fprocess/6.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/symfony%2fprocess/6.4.0/6.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/symfony%2fprocess/6.4.0/6.4.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>symfony/console (symfony/console)</summary>

### [`v6.4.2`](https://togithub.com/symfony/console/releases/tag/v6.4.2)

[Compare
Source](https://togithub.com/symfony/console/compare/v6.4.1...v6.4.2)

**Changelog**
(symfony/console@v6.4.1...v6.4.2)

- bug
[symfony/symfony#52940](https://togithub.com/symfony/symfony/issues/52940)
\[Console] Fix color support check on non-Windows platforms
([@&#8203;theofidry](https://togithub.com/theofidry))
- bug
[symfony/symfony#52941](https://togithub.com/symfony/symfony/issues/52941)
\[Console] Fix xterm detection
([@&#8203;theofidry](https://togithub.com/theofidry))

</details>

<details>
<summary>symfony/process (symfony/process)</summary>

### [`v6.4.2`](https://togithub.com/symfony/process/releases/tag/v6.4.2)

[Compare
Source](https://togithub.com/symfony/process/compare/v6.4.0...v6.4.2)

**Changelog**
(symfony/process@v6.4.1...v6.4.2)

- bug
[symfony/symfony#52864](https://togithub.com/symfony/symfony/issues/52864)
\[HttpClient]\[Mailer]\[Process] always pass microseconds to usleep as
integers ([@&#8203;xabbuh](https://togithub.com/xabbuh))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/Lendable/composer-license-checker).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
fabpot added a commit that referenced this pull request Jan 19, 2024
… if the output (theofidry)

This PR was merged into the 5.4 branch.

Discussion
----------

[Console] Only execute additional checks for color support if the output

is a TTY

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #53460
| License       | MIT

As reported in #53460, the modifications done in #52940 are incorrect as it results in detecting that the stream can support colors despite not being a TTY.

Rather than doing a simple revert which would re-introduce the pre-existing issue that #52940 attempted to fix, this PR checks if the output is a TTY based on Composer's code and does this check before anything else.

Indeed a TTY only means that colors _may_ be supported, so the various checks that we were doing do make sense to be done but should be done after this TTY (so `Hyper` is not an exception, it can be a TTY or not).

Commits
-------

2e96b22 [Console] Only execute additional checks for color support if the output is a TTY
@mallardduck
Copy link

I may have encountered a bug in my application that seems to be related to this PR.

The "short version" of the issue is that I have CLI commands who's output get piped to other commands. And this has stopped working when updating to v6.4.2.

From what I can tell debugging the commands output with cat -v - I see additional color codes on the strings after this PR that break subsequent commands.

In both the before and after, the text will print in green (info) colors. However with 6.4.1 the text pipes to subsequent commands fine. But in 6.4.2 the text has color codes embedded to it which breaks subsequent commands.

^[[32mTHIS IS THE TEXT^[[39m

In my environment I'm on a Mac, using iTerm.

echo $TERM
xterm-256color
echo $TERM_PROGRAM
iTerm.app

Ultimately I'm wondering if this is expected in my environment after this change, or if this is a new bug/regression? If this is expected, how can I continue to use the info() output text and maintain ability to pipe text?

@xabbuh
Copy link
Member

xabbuh commented Jan 23, 2024

@mallardduck Can you check if the behaviour you experience vanishes with #53576?

@mallardduck
Copy link

@xabbuh - thanks for that, applying that patch manually to the vendor files fixes it.

@tamr
Copy link

tamr commented Feb 18, 2024

Just updated the composer and noticed the missing colors. I'm using Kitty(cyd01) with termtype set to tmux-256color.
Shouldn't there be another check?
str_ends_with(getenv('TERM'), '256color ')

@theofidry
Copy link
Contributor Author

theofidry commented Feb 18, 2024

@tamr this would require more information. tmux-256color is captured by this regex so there is likely something else going on (provided the version you are using has this patch).

If you do please open an issue with the required information to fix it 🙏

github-merge-queue bot pushed a commit to Lendable/composer-license-checker that referenced this pull request Mar 2, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [symfony/console](https://symfony.com)
([source](https://togithub.com/symfony/console)) | `6.4.4` -> `7.0.4` |
[![age](https://developer.mend.io/api/mc/badges/age/packagist/symfony%2fconsole/7.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/symfony%2fconsole/7.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/symfony%2fconsole/6.4.4/7.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/symfony%2fconsole/6.4.4/7.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [symfony/process](https://symfony.com)
([source](https://togithub.com/symfony/process)) | `6.4.4` -> `7.0.4` |
[![age](https://developer.mend.io/api/mc/badges/age/packagist/symfony%2fprocess/7.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/symfony%2fprocess/7.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/symfony%2fprocess/6.4.4/7.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/symfony%2fprocess/6.4.4/7.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>symfony/console (symfony/console)</summary>

### [`v7.0.4`](https://togithub.com/symfony/console/releases/tag/v7.0.4)

[Compare
Source](https://togithub.com/symfony/console/compare/v7.0.3...v7.0.4)

**Changelog**
(symfony/console@v7.0.3...v7.0.4)

- bug
[symfony/symfony#54009](https://togithub.com/symfony/symfony/issues/54009)
\[Console] Fix display of vertical Table on Windows OS
([@&#8203;VincentLanglet](https://togithub.com/VincentLanglet))
- bug
[symfony/symfony#54001](https://togithub.com/symfony/symfony/issues/54001)
\[Console] Fix display of Table on Windows OS
([@&#8203;VincentLanglet](https://togithub.com/VincentLanglet))
- bug
[symfony/symfony#53707](https://togithub.com/symfony/symfony/issues/53707)
\[Console] Fix color support for TTY output
([@&#8203;theofidry](https://togithub.com/theofidry))
- bug
[symfony/symfony#53711](https://togithub.com/symfony/symfony/issues/53711)
\[Console] Allow false as a $shortcut in InputOption
([@&#8203;jayminsilicon](https://togithub.com/jayminsilicon))

### [`v7.0.3`](https://togithub.com/symfony/console/releases/tag/v7.0.3)

[Compare
Source](https://togithub.com/symfony/console/compare/v7.0.2...v7.0.3)

**Changelog**
(symfony/console@v7.0.2...v7.0.3)

- bug
[symfony/symfony#53516](https://togithub.com/symfony/symfony/issues/53516)
\[Console] Allow '0' as a $shortcut in InputOption.php
([@&#8203;lawsonjl-ornl](https://togithub.com/lawsonjl-ornl))
- bug
[symfony/symfony#53576](https://togithub.com/symfony/symfony/issues/53576)
\[Console] Only execute additional checks for color support if the
output ([@&#8203;theofidry](https://togithub.com/theofidry))

### [`v7.0.2`](https://togithub.com/symfony/console/releases/tag/v7.0.2)

[Compare
Source](https://togithub.com/symfony/console/compare/v7.0.1...v7.0.2)

**Changelog**
(symfony/console@v7.0.1...v7.0.2)

- bug
[symfony/symfony#52940](https://togithub.com/symfony/symfony/issues/52940)
\[Console] Fix color support check on non-Windows platforms
([@&#8203;theofidry](https://togithub.com/theofidry))
- bug
[symfony/symfony#52941](https://togithub.com/symfony/symfony/issues/52941)
\[Console] Fix xterm detection
([@&#8203;theofidry](https://togithub.com/theofidry))

### [`v7.0.1`](https://togithub.com/symfony/console/releases/tag/v7.0.1)

[Compare
Source](https://togithub.com/symfony/console/compare/v7.0.0...v7.0.1)

**Changelog**
(symfony/console@v7.0.0...v7.0.1)

-   no significant changes

### [`v7.0.0`](https://togithub.com/symfony/console/releases/tag/v7.0.0)

[Compare
Source](https://togithub.com/symfony/console/compare/v6.4.4...v7.0.0)

**Changelog**
(symfony/console@v7.0.0-RC2...v7.0.0)

-   no significant changes

</details>

<details>
<summary>symfony/process (symfony/process)</summary>

### [`v7.0.4`](https://togithub.com/symfony/process/releases/tag/v7.0.4)

[Compare
Source](https://togithub.com/symfony/process/compare/v7.0.3...v7.0.4)

**Changelog**
(symfony/process@v7.0.3...v7.0.4)

- bug
[symfony/symfony#54006](https://togithub.com/symfony/symfony/issues/54006)
\[Process] Fix the `command -v` exception (@&#8203;kayw-geek)
- bug
[symfony/symfony#53821](https://togithub.com/symfony/symfony/issues/53821)
\[Process] Fix Inconsistent Exit Status in proc_get_status for PHP
Versions Below 8.3 ([@&#8203;Luc45](https://togithub.com/Luc45))

### [`v7.0.3`](https://togithub.com/symfony/process/releases/tag/v7.0.3)

[Compare
Source](https://togithub.com/symfony/process/compare/v7.0.2...v7.0.3)

**Changelog**
(symfony/process@v7.0.2...v7.0.3)

- bug
[symfony/symfony#53481](https://togithub.com/symfony/symfony/issues/53481)
\[Process] Fix executable finder when the command starts with a dash
([@&#8203;kayw-geek](https://togithub.com/kayw-geek))

### [`v7.0.2`](https://togithub.com/symfony/process/releases/tag/v7.0.2)

[Compare
Source](https://togithub.com/symfony/process/compare/v7.0.0...v7.0.2)

**Changelog**
(symfony/process@v7.0.1...v7.0.2)

- bug
[symfony/symfony#52864](https://togithub.com/symfony/symfony/issues/52864)
\[HttpClient]\[Mailer]\[Process] always pass microseconds to usleep as
integers ([@&#8203;xabbuh](https://togithub.com/xabbuh))

### [`v7.0.0`](https://togithub.com/symfony/process/releases/tag/v7.0.0)

[Compare
Source](https://togithub.com/symfony/process/compare/v6.4.4...v7.0.0)

**Changelog**
(symfony/process@v7.0.0-RC2...v7.0.0)

-   no significant changes

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/Lendable/composer-license-checker).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMjAuMiIsInVwZGF0ZWRJblZlciI6IjM3LjIyMC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants