Merge pull request #2745 from MikeMcQuaid/tty-width

tty: handle non-tty stdin.
This commit is contained in:
Mike McQuaid 2017-06-07 08:45:53 +01:00 committed by GitHub
commit cfc40196f2

View File

@ -6,7 +6,10 @@ module Tty
end
def width
(`/bin/stty size`.split[1] || 80).to_i
width = `/bin/stty size 2>/dev/null`.split[1]
width ||= `/usr/bin/tput cols 2>/dev/null`.split[0]
width ||= 80
width.to_i
end
def truncate(string)