bacongravy / macinbox

Puts macOS in a Vagrant box
Other
662 stars 45 forks source link

Fix progress bar crashing when macinbox is not run in a TTY #33

Closed milch closed 5 years ago

milch commented 5 years ago

The progress_bar function is accessing STDOUT.winsize which assumes that the program is run in a tty, which crashes with a ENOTTY error code without this change.

Right now I'm monkey patching Macinbox to make it work:

module MacinboxPatch
  def progress_bar(*args)
    return '' unless STDOUT.tty?

    super(*args)
  end
end

class Macinbox::Task
  class << self
    prepend MacinboxPatch
  end
end

With this change in place Macinbox simply does not print the progress_bar, which is the desired behaviour for my use-case.

bacongravy commented 5 years ago

Hi, @milch ! Thank you for this PR. I'm glad you were able to work around the issue.

I'm not going to merge this PR as-is, but instead I will re-factor the Task class directly to skip printing the progress bar when not connected to a tty.

milch commented 5 years ago

Sure thing, that works for me

bacongravy commented 5 years ago

I addressed this with https://github.com/bacongravy/macinbox/commit/2cf934208bee948532ce69542b25735918a79093.