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

custom prompt usability issues

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.1.0
    • Affects Version/s: None
    • Component/s: Shell
    • Labels:
      None

      1) If there is an error evaluating a prompt function, prompt becomes undefined. Might want to set to a default prompt instead.

      >
      > prompt = '> '
      >
      > prompt = function()

      { return c; }

      function ()

      { return c; } Tue Sep 6 13:45:42 ReferenceError: c is not defined (shell):1 undefined Tue Sep 6 13:45:47 ReferenceError: c is not defined (shell):1 undefined Tue Sep 6 13:45:48 ReferenceError: c is not defined (shell):1 undefined 2) setting prompt to a regex has strange results > prompt = /a/ /a/ Tue Sep 6 15:22:44 SyntaxError: no input for /a/ :1 undefined 3) new lines in prompt mess up shell handling of current line and use of history. Other unusual characters (eg \b) and long lines seem to cause problems too. If the prompt line is wider than my terminal window, I never see anything other than the prompt and every time I type a character I get a new line with the prompt on it. Aaron-Staples-MacBook-Pro:mongo aaron$ ./mongo MongoDB shell version: 2.0.0-rc2-pre- connecting to: test > prompt = "you are special!\n> " you are special! > you are special! > db.c.count() 1 you are special! you are special!> you are special!> db.c.count() <<<----- pressing backspace repeatedly you are special!> db.c.count( you are special!> db.c.count you are special!> db.c.coun you are special!> db.c.cou you are special!> db.c.co you are special!> db.c.c > db.c. find() { "_id" : ObjectId("4e66a1acc98ce70998274933") }

      you are special!
      you are special!>
      you are special!> db.c.find() <<<----- pressing up arrow
      you are special!> db.c.count()
      you are special!> prompt = "you are special!\n> "
      you are special!> db.c.count()
      you are special!> prompt = "you are special!\n> "
      you are special!> db.c.count()
      you are special!> db.c.find()
      you are special!>
      you are special!> db.c.find()
      you are special!> db.c.count()
      you are special!> prompt = "you are special!\n> "
      you are special!> db.c.count()
      you are special!> db.c.find()
      you are special!>
      you are special!> db.c.find()
      >

      connecting to: test
      > ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
      ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
      ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

      4) Don't know if we want to allow them, but shell helpers aren't available in the prompt function:

      > prompt = function()

      { use foo; return db.c.count(); }

      Tue Sep 6 15:47:12 SyntaxError: missing ; before statement (shell):1

      > prompt = function()

      { exit; }

      function () {
      exit;
      }
      Tue Sep 6 15:48:25 ReferenceError: exit is not defined (shell):1
      undefined

            Assignee:
            tad Tad Marshall
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: