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

Allow non zero return code to be specified by javascript shell

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.7.2
    • Affects Version/s: None
    • Component/s: Shell
    • Labels:
      None

      Currently the mongo shell supports returning a non zero code only when invoked with the name of a script (see http://jira.mongodb.org/browse/SERVER-1148 ) and in that case, support simply a success or failure code.

      However, I would suggest supporting returning a user-defined non-zero exit code upon exiting (possibly wiht some extention of the "exit" syntax? - see http://jira.mongodb.org/browse/SERVER-683 )

      Use cases:
      1) running the mongo client with dynamically generated javascript - i.e. to pass parameters dynamically in to some system-maintenance script.
      2) When you wish to allow distinct return codes to indicate type or magnitude of execution failure, as per other unix utilities.

      This would ease the usage of the JS shell as a system maintenance toolkit which is very useful as long as
      1) javascript is the "blessed" mongodb language (JSON, $where clauses, M/R JS - it seems to be!)
      2) while db.eval is blocking (and even, were db.eval non-blocking) for tasks that you would not wish to run in the server process
      3) duplicating code between javascript and other client languages is to be minimised.

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            howthebodyworks dan
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: