docs: public boolean confirm(String what, boolean def) {
          String yn = def ? "Y/n" : "y/N";
          formatln("%s [%s]:", what, yn);
  
          try {
              for (;;) {
                  Char c = read();
                  if (c == null) {
                      throw new IOException("End of stream.");
                  }
                  int cp = c.asInteger();
                  if (cp == Char.CR || cp == Char.LF) {
                      print(def ? " Yes." : " No.");
                      return def;
                  }
                  if (cp == 'y' || cp == 'Y') {
                      print(" Yes.");
                      return true;
                  }
                  if (cp == 'n' || cp == 'N' || cp == Char.DEL) {
                      print(" No.");
                      return false;
                  }
                  if (cp == Char.ESC || cp == Char.ABR || cp == Char.EOF) {
                      throw new IOException("User interrupted: " + c.asString());
                  }
                  if (cp == ' ' || cp == '\t') {
                      continue;
                  }
                  format("\r%s%s [%s]: '%s' is not valid input.",
                         Control.CURSOR_ERASE,
                         what, yn, c.asString());
              }
          } catch (IOException e) {
              throw new UncheckedIOException(e);
          }
      }