diff --git a/lib/puppet/util/terminal.rb b/lib/puppet/util/terminal.rb index 8674a4956..74d8930ea 100644 --- a/lib/puppet/util/terminal.rb +++ b/lib/puppet/util/terminal.rb @@ -1,15 +1,17 @@ module Puppet::Util::Terminal - class << self - # Borrowed shamelessly from Thor, who borrowed this from Rake. - def width - if Puppet.features.posix? - result = %x{stty size 2>/dev/null}.split[1] || - %x{tput cols 2>/dev/null}.split[0] || - '80' - end - return result.to_i - rescue - return 80 + # Attempts to determine the width of the terminal. This is currently only + # supported on POSIX systems, and relies on the claims of `stty` (or `tput`). + # + # Borrowed shamelessly from Thor, who borrowed this from Rake. + # @return [Number] The column width of the terminal. Defaults to 80 columns. + def self.width + if Puppet.features.posix? + result = %x{stty size 2>/dev/null}.split[1] || + %x{tput cols 2>/dev/null}.split[0] || + '80' end + return result.to_i + rescue + return 80 end end