lint,diff,push: strip linter annotation newlines if non-TTY STDERR #211
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Linter annotation messages sometimes contain embedded newlines, which can make automated parsing of these messages difficult. This PR adjusts linter output to strip embedded newlines whenever STDERR isn't a terminal. In this situation, spaces are now used in place of newlines, so each linter annotation is guaranteed to be a single log line.
Note that non-linter-related log messages may still contain embedded newlines. In that situation, if STDERR isn't a terminal, each log line repeats the log message header with timestamp and severity.
The logic in this PR only pays attention to STDERR (and not STDOUT) since Skeema log messages always go to STDERR. In
skeema diff
andskeema push
, STDOUT is used for emitting SQL. Inskeema lint
, STDOUT is currently unused.This PR also adds some utility functions for making it easier to check whether a file descriptor is a terminal.