Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1110

All is not --quiet with --eval in mongo shell

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 Minor - P4
    • No version
    • Affects Version/s: None
    • Component/s: Embedded Shell
    • Environment:
      OS: Linux
      Distro: Ubuntu 18.04
      Mongosh version: 1.1.9
      MongoDB version: 5.0.1
      Mongo version: all
    • Not Needed

      Problem Statement/Rationale

      What is going wrong? What action would you like the Engineering team to take?

      The mongo shells: mongosh and the older mongo echo the result of the last --eval expression when the --quiet switch has been set.

      This is particularly annoying when using the shell to generate output files from mongodb. Files need to be cleansed of the extraneous output. Both mongosh and mongo apparently echo some output to STDOUT, so the results of --eval end up in the output. This appears to be true only for the last expression evaluated by --eval, e.g. --eval 'expr1;expr2;expr3'; only the result of "expr3" will be seen in echoed output.

      I am aware that this behavior has be reported in: SERVER-4391, SERVER-23810(closed), SERVER-27159(closed), however, it remains unresolved. The proposed workaround in SERVER-4391 of the "void" solution is a clumsy, especially when embedding in a Bash shell script, at best. I would really like to see this fixed as it's the only way that I know of to pass arguments into a mongosh script.

      Steps to Reproduce

      How could an engineer replicate the issue you’re reporting?

      Using the attached demo script:
      > mongosh --quiet --eval 'FIRST="Al";LAST="Paca"' echoTest.js

      Expected Results

      What do you expect to happen?

      Demonstrate extraneous --eval output to STDOUT.
      First name: Al
      Last name: Paca
      Hi my name is: Al Paca

      Actual Results

      What do you observe is happening?

      Paca
      Demonstrate extraneous --eval output to STDOUT.
      First name: Al
      Last name: Paca

      Additional Notes

      Any additional information that may be useful to include.

            Assignee:
            Unassigned Unassigned
            Reporter:
            marsh.giguere@gmail.com Marshall Giguere
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: