Skip to content
Snippets Groups Projects
Commit 13d9305f authored by Markus Reiter's avatar Markus Reiter
Browse files

Cache `Tty.width`, since it is used heavily because of `ohai`.

parent 502b393d
No related branches found
No related tags found
No related merge requests found
......@@ -6,10 +6,12 @@ module Tty
end
def width
width = `/bin/stty size 2>/dev/null`.split[1]
width = `/usr/bin/tput cols 2>/dev/null`.split[0] if width.to_i.zero?
width ||= 80
width.to_i
@width ||= begin
width = `/bin/stty size 2>/dev/null`.split[1]
width = `/usr/bin/tput cols 2>/dev/null`.split[0] if width.to_i.zero?
width ||= 80
width.to_i
end
end
def truncate(string)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment