cut_term_width fix
This commit is contained in:
parent
e47610c4d0
commit
8087665ee0
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -24,7 +25,14 @@ def pad_to_width(line: bytes, width: int) -> str:
|
||||||
return output_line.decode('utf-8')
|
return output_line.decode('utf-8')
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
width = int(sys.argv[1])
|
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')
|
lines = open(0, 'rb').read().strip(b'\n').split(b'\n')
|
||||||
for line in lines:
|
for line in lines:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue