diff --git a/lib/puppet/util/terminal.rb b/lib/puppet/util/terminal.rb index 74d8930ea..8674a4956 100644 --- a/lib/puppet/util/terminal.rb +++ b/lib/puppet/util/terminal.rb @@ -1,17 +1,15 @@ module Puppet::Util::Terminal - # 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' + 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 end - return result.to_i - rescue - return 80 end end