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

Command line history in the shell could be better

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.1.0
    • Affects Version/s: 2.0.0
    • Component/s: Shell
    • Labels:
      None
    • Environment:
      Any

      The command line history feature of the shell tends to accumulate multiple copies of commands when it is used. The only test for preventing duplicate commands from being stored is a comparison with the immediately preceding command, so if you up-arrow three times and hit return, you get a new copy of the old command. The bash shell seems to be a lot smarter about this. We should try to be closer to bash in handling history.

      A second thought (sorry for two thoughts in one bug report, but they are related) is that the Windows command line (cmd.exe) has a feature that bash doesn't have. In Windows, if your most recent command was retrieved by using up-arrow, then that position is remembered as a "special" location, and if your next keystroke is down-arrow, then the command that followed the one that you just retrieved is recalled, and the special location is updated. This has no effect on what happens on up-arrow and doesn't "rotate the list" or anything like that. It's just a simple hack that lets you issue five commands in sequence and then recall them in the same sequence later. It doesn't break compatibility with bash or other shells because other shells just ignore a down-arrow when you haven't already recalled a command with up-arrow. The reason that I mention this is that it can be very convenient, and Windows users might try it and hope that it is there. If we implement it, we could consider doing it for all versions and not just Windows versions. It can save a lot of keystrokes in some situations and feel very friendly.

      > my first command [hit enter]
      > my second command [enter]
      > my third command [enter]
      > [up-arrow] twice shows "my second command" ... [hit enter]
      > [down-arrow] on Windows (DOS) command line, this shows "my third command", on bash it does nothing

      At the Windows (DOS) command line, down-arrow behaves just like bash if your immediately preceding entry wasn't a recalled command or if the command was edited (changed) before you hit return. Its only appearance as a feature is when you are recalling a sequence of commands.

            Assignee:
            tad Tad Marshall
            Reporter:
            tad Tad Marshall
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: