Here's a simple patch to tweak the behavior of (comint-get-old-input-default) to do what the docstring says it should do. Example: 1. emacs -Q 2. M-x shell 3. seq 5 [RET] This produces the output 1 2 3 4 5 4. Move point to "3" 5. (comint-get-old-input-default) According to the docstring, this should return the current line; i.e. "3". Instead it returns "3\n4\n5\n" + the next prompt. This behavior can produce lots of unwanted commands executing accidentally, and it goes against what the docstring says.