This is a serious bug in M-x shell. It is not a bash or dash bug. It is not a readline bug. It does not happen in xterm. It does not happen when using pipes or backticks to get the input. It only happens in M-x shell... when one gives lines longer than ~4096 characters. Actually it is not buffer overflow, but buffer truncation, with NO WARNING to the user. One day the wrong file will get removed via this mess. In GNU Emacs 24.0.50.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0) of 2010-05-01 on elegiac, modified by Debian (emacs-snapshot package, version 1:20100501-1)