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

cmd/errtrace: Best-effort detection of tty stdin using char device #84

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

prashantv
Copy link
Contributor

Follow-up to #78 and #82.

When stdin is implicitly used, we wait for 200ms for input before printing a message to stderr to notify the user that we're reading from stdin to avoid confusion. This added some complexity in the read path, as well as the testing because of the background goroutine that waits for a timeout before printing to stderr.

This is an alternative approach that does a best-effort detection of a TTY by checking if stdin is a character device.

@prashantv prashantv requested a review from abhinav January 9, 2024 06:33
@prashantv
Copy link
Contributor Author

Tested the following cases:

  • errtrace FILE
  • errtrace < FILE
  • errtrace -
  • errtrace

And it worked fine on Linux, MacOS and Windows.

@prashantv prashantv force-pushed the prashant/stdin-check-tty branch from 9d4abff to abbc81d Compare January 9, 2024 06:38
Follow-up to #78 and #82.

When stdin is implicitly used, we wait for 200ms for input before
printing a message to stderr to notify the user that we're reading
from stdin to avoid confusion. This added some complexity in the read
path, as well as the testing because of the background goroutine that
waits for a timeout before printing to stderr.

This is an alternative approach that does a best-effort detection of a
TTY by checking if stdin is a character device.
@prashantv prashantv force-pushed the prashant/stdin-check-tty branch from abbc81d to 42bfb99 Compare January 9, 2024 06:51
@prashantv prashantv merged commit 4a522e3 into main Jan 9, 2024
10 of 11 checks passed
@prashantv prashantv deleted the prashant/stdin-check-tty branch January 9, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants