(I think that this is an Emacs bug, rather than a Debian packaging bug. I am using Emacs 26.1, amd64.) In shell-mode, the command history can get confused by bash's syntax for fd redirection, e.g. by "command 2> filename", and sometimes inserts a space between the fd and the ">". Here is a minimal example. $ emacs -q -nw M-x shell<ENTER> echo 2> /dev/null<ENTER> !echo<ENTER> M-p [to get the previous command in the history] and the *shell* buffer looks like: $ echo 2> /dev/null $ !echo echo 2> /dev/null [so far, so good] $ echo 2 > /dev/null [that spells trouble!] The problem is the space inserted between the "2" and the ">", which of course changes the meaning of the command.