Using M-x shell, I have encountered a problem with commandlines being truncated to 4095 characters.

Steps to reproduce:

  1. perl -e 'print "0" x 5000 . "\n"'
  2. Select output for next command
  3. echo <5000 zeros> > /tmp/emacs_5000

Expected behaviour:

wc /tmp/emacs_5000 should return

1 1 5001 /tmp

Current behaviour:

4090 zeros are output into the shell.

Interpretation: only the first 4095 characters (4090 output + 'echo ') are passed to the shell process.

Is my interpretation correct?

Is the a way to fix it?

  • This sounds like process-connection-type specifying a pty. When terminal input is subject to the line discipline provided for TTYs by the OS, it may impose a maximum line size (4096 chars in GNU/Linux, for example) with larger lines being truncated. I'm not sure whether not using a pty is any kind of issue for M-x shell, but see whether M-: (setq process-connection-type nil) before starting the shell changes things. – phils Mar 28 at 7:32
  • n.b. I'm guessing a bit, because I can't replicate the problem with the given recipe; but I've encountered this kind of issue in other situations. – phils Mar 28 at 7:35
  • I believe debbugs.gnu.org/cgi/bugreport.cgi?bug=6149#19 also describes this problem. – phils Mar 28 at 10:14
  • (The latter recipe I can reproduce in both 26.3 and 27.0.90; I'm not sure why I couldn't replicate the issue with your recipe). – phils Mar 28 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.