mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Supress stderr when TERM is unset
This commit is contained in:
parent
4da968a5ea
commit
7321108083
1 changed files with 4 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
|
@ -9,9 +10,11 @@ from pre_commit import five
|
|||
|
||||
# TODO: smell: import side-effects
|
||||
try:
|
||||
if not os.environ.get('TERM'):
|
||||
raise OSError('Cannot determine width without TERM')
|
||||
COLS = int(
|
||||
subprocess.Popen(
|
||||
['tput', 'cols'], stdout=subprocess.PIPE,
|
||||
('tput', 'cols'), stdout=subprocess.PIPE,
|
||||
).communicate()[0] or
|
||||
# Default in the case of no terminal
|
||||
80
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue