require 'io/console'

module PassFail

  def pass?
    begin
      system("stty raw -echo -icanon isig")
      str = STDIN.getc.chr
      if str.chr == "p"
        true
      elsif str.chr =="\r"
        true
      elsif str.chr == "f"
        false
      elsif str.chr == "x"
        false
      else
        # Need this to return to the start if any other key
      end
    ensure
      system("stty -raw echo icanon")
    end
  end

end

World(PassFail)

require 'io/console'

module PassFail

  def pass?
    state = 'stty -g'
    begin
      system("stty raw -echo isig")
      str = STDIN.getc.chr
      case
      when str.chr == "p"
        true
      when str.chr =="\r"
        true
      when str.chr == "f"
        false
      when str.chr == "x"
        false
      else
        # something
      end
    ensure
      system("stty -raw echo")
    end
  end

end

World(PassFail)

Fix issue with terminal not reverting to normal after running
Fix issue with terminal not reverting to normal after running
