Skip to content

A feature-rich command-line audio/video downloader

Use subprocess to call stty size when COLUMNS is not set

Philipp Hagemeister4f2a5e06da89
diff --git a/youtube-dl b/youtube-dl
index 1ae68b2b5d..32bd99e98e 100755
--- a/youtube-dl
+++ b/youtube-dl
@@ -2996,11 +2996,12 @@ def parseOpts():
if columns:
return int(columns)
- # TODO: Breaks on phihag's system
- #if sys.platform.startswith('linux'):
- # try:
- # return os.popen('stty size', 'r').read().split()[1]
- # except: pass
+ try:
+ sp = subprocess.Popen(['stty', 'size'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out,err = sp.communicate()
+ return out.split()[1]
+ except:
+ pass
return None
max_width = 80