mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-05-08 00:09:15 -05:00
Merge pull request #261 from pre-commit/no_tput_stderr
Supress stderr when TERM is unset
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -9,9 +10,11 @@ from pre_commit import five
|
|||||||
|
|
||||||
# TODO: smell: import side-effects
|
# TODO: smell: import side-effects
|
||||||
try:
|
try:
|
||||||
|
if not os.environ.get('TERM'):
|
||||||
|
raise OSError('Cannot determine width without TERM')
|
||||||
COLS = int(
|
COLS = int(
|
||||||
subprocess.Popen(
|
subprocess.Popen(
|
||||||
['tput', 'cols'], stdout=subprocess.PIPE,
|
('tput', 'cols'), stdout=subprocess.PIPE,
|
||||||
).communicate()[0] or
|
).communicate()[0] or
|
||||||
# Default in the case of no terminal
|
# Default in the case of no terminal
|
||||||
80
|
80
|
||||||
|
|||||||
Reference in New Issue
Block a user