Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-19710

shellPrintHelper() and shellPrint() printing conventions not well defined

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • Server Tooling & Methods
    • ALL

      shellPrintHelper() usually calls print(), but in the case of an object with a shellPrint() function it instead returns the result of calling shellPrint().

      Sometimes (often?) shellPrint() calls print() (eg. DBQuery), but sometimes it returns a string (eg. WriteResult). In this latter case, the printing happens via printResult = true being passed to ImplScope::exec() when shellPrintHelper() is run.

      This is all a bit confusing and inconsistent. We should settle on print()ing conventions for shellPrint() and shellPrintHelper(), and then audit all uses to make them compliant. The possible options are:

      1. shellPrint() and shellPrintHelper() always call print() in their dynamic scope, and never return any value.
      2. shellPrint() and shellPrintHelper() never call print() in their dynamic scope, and always return the string to be printed. This is then actually printed via scope->exec()/printResult (as above).

      I'm in favour of the latter, since it allows the exact shell output to be determined programmatically (and potentially tested in jstests) by the expression "shellPrintHelper(foo)", rather than having to mess around capturing print() calls ala SERVER-19368.

            Assignee:
            backlog-server-stm Backlog - Server Tooling and Methods (STM) (Inactive)
            Reporter:
            kevin.pulo@mongodb.com Kevin Pulo
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: