cut_term_width fix

This commit is contained in:
cubernetes 2023-08-13 21:07:29 +02:00
parent e47610c4d0
commit 8087665ee0
1 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
import os
import re
import sys
@ -24,6 +25,13 @@ def pad_to_width(line: bytes, width: int) -> str:
return output_line.decode('utf-8')
def main() -> int:
if len(sys.argv) != 2:
columns = os.environ.get('COLUMNS')
if columns:
width = int(columns)
else:
width = 20
else:
width = int(sys.argv[1])
lines = open(0, 'rb').read().strip(b'\n').split(b'\n')
for line in lines: