Skip to content

Commit 7321108

Browse files
committed
Supress stderr when TERM is unset
1 parent 4da968a commit 7321108

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

pre_commit/output.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import unicode_literals
22

3+
import os
34
import subprocess
45
import sys
56

@@ -9,9 +10,11 @@
910

1011
# TODO: smell: import side-effects
1112
try:
13+
if not os.environ.get('TERM'):
14+
raise OSError('Cannot determine width without TERM')
1215
COLS = int(
1316
subprocess.Popen(
14-
['tput', 'cols'], stdout=subprocess.PIPE,
17+
('tput', 'cols'), stdout=subprocess.PIPE,
1518
).communicate()[0] or
1619
# Default in the case of no terminal
1720
80

0 commit comments

Comments
 (0)