Title: regression with tty detection · Issue #1459 · pre-commit/pre-commit · GitHub
Open Graph Title: regression with tty detection · Issue #1459 · pre-commit/pre-commit
X Title: regression with tty detection · Issue #1459 · pre-commit/pre-commit
Description: A recent regression was introduced via #1382 which broke detection on various conditions. For example, on my MacOS host, only stdout and stdin report True on isatty() while stderr reports False, even if in reality there is no problem wit...
Open Graph Description: A recent regression was introduced via #1382 which broke detection on various conditions. For example, on my MacOS host, only stdout and stdin report True on isatty() while stderr reports False, ev...
X Description: A recent regression was introduced via #1382 which broke detection on various conditions. For example, on my MacOS host, only stdout and stdin report True on isatty() while stderr reports False, ev...
Opengraph URL: https://github.com/pre-commit/pre-commit/issues/1459
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"regression with tty detection","articleBody":"A recent regression was introduced via https://github.com/pre-commit/pre-commit/pull/1382 which broke detection on various conditions.\r\n\r\nFor example, on my MacOS host, only `stdout` and `stdin` report True on `isatty()` while `stderr` reports False, even if in reality there is no problem with sending ANSI to stderr.\r\n\r\nProbably we should rely solely on `stdout` for the test or to assure that we respect it for each tty.\r\n\r\nThis issue is not happening with lots of people because only few of them use a method to colorize stderr, which apparently is what has a side-effect of marking it as a non tty. \r\n\r\nExample of zsh snippet from `~/.zshrc` that does this:\r\n```bash\r\n export STDERRED_ESC_CODE=\"$fg[red]\"\r\n if [[ \"$STDERR_COLORIZE\" != $$ ]]; then\r\n if (( $+commands[colorize] )); then\r\n exec 2>>(colorize $fg[yellow] $reset_color > /dev/tty &)\r\n else\r\n exec 2>>(while read line; do\r\n print ${fg[yellow]}$line$reset_color > /dev/tty; print -n $'\\0'; done &)\r\n fi\r\n export STDERR_COLORIZE=$$\r\n fi\r\n```\r\n\r\nOnce this runs you no longer gave a tty-enabled stderr.\r\n\r\nVast majority of CLI tools I know are using `sys.stdout.isatty()`, the only other exception I know is `mypy`. https://bixense.com/clicolors/ seems to support that approach too.\r\n\r\nRegarding the never-ending struggle to control ANSI on/off behavior where each tool invented its own implementation and variables to configure behavior, it seems that someone realized that maybe is time to do something about it https://no-color.org/ :)","author":{"url":"https://github.com/ssbarnea","@type":"Person","name":"ssbarnea"},"datePublished":"2020-05-15T12:23:27Z","url":"https://github.com/pre-commit/pre-commit/issues/1459"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a89ec777-ff16-0a9e-370f-769a9ed1b6ae |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E494:1188C0:144A5E5:1AD7058:6B066265 |
| html-safe-nonce | eba4cbd5c00b7a1abbc4b7d09a8f1eb159a2cf717b9c1d082934367c5853fdd6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDk0OjExODhDMDoxNDRBNUU1OjFBRDcwNTg6NkIwNjYyNjUiLCJ2aXNpdG9yX2lkIjoiNzU4ODkyNjU2MzQ4NDU5MDY5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | eb4bcf0fbf8b0c817fda27fafbd290cc52c3f8d663b4b5c2e18173bf04614123 |
| hovercard-subject-tag | issue:618928648 |
| github-keyboard-shortcuts | repository,issues,commits,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pre-commit/pre-commit/1459/issue_layout |
| twitter:image | https://opengraph.githubassets.com/990a6f1153485ed7f33dd4d959ed5ebfbb84e495104a8e97db80281c1a6b721f/pre-commit/pre-commit/issues/1459 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/990a6f1153485ed7f33dd4d959ed5ebfbb84e495104a8e97db80281c1a6b721f/pre-commit/pre-commit/issues/1459 |
| og:image:alt | A recent regression was introduced via #1382 which broke detection on various conditions. For example, on my MacOS host, only stdout and stdin report True on isatty() while stderr reports False, ev... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ssbarnea |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6324e6ac990fb6befbec840cc0e102a1071c339bfe8f9826bb12de2e3ba1d297 |
| turbo-cache-control | no-preview |
| go-import | github.com/pre-commit/pre-commit git https://github.com/pre-commit/pre-commit.git |
| octolytics-dimension-user_id | 6943086 |
| octolytics-dimension-user_login | pre-commit |
| octolytics-dimension-repository_id | 17689377 |
| octolytics-dimension-repository_nwo | pre-commit/pre-commit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 17689377 |
| octolytics-dimension-repository_network_root_nwo | pre-commit/pre-commit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7f0aa75f4141d440c6110dc31af7ea7797abb6c4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width