Input pasted into shell gets silently truncated to 4095 bytes

Problem description:
Pasting a line exceeding 4095 bytes in length into shell gets silently truncated instead of getting passed as is to stdin.

Expected behavior:
All pasted bytes appear on stdin of a reading application.

Actual behavior:
The input is truncated at 4095 bytes. Interestingly, if I paste something that has a long line followed by a second line after a line break, the second line makes it through. So there’s probably some line buffering going on somewhere that assumes a max line length of 4k.

Steps to reproduce:
On a shell:

  • cat - > file, then paste a long string (making sure not to include line breaks)
  • ls -l file will show show a file size of 4095 bytes regardless of whether the pasted string was longer

Bug appears at this link:
Well, not exactly, but I encountered this in the context of the AOC 2022 day 17 puzzle, which features a single long line of input. Just in case it’s useful, this is the repl, but the reproducer above is probably all you need.

Browser/OS/Device:
Reproducible both in the web interface (as of 2022/12/17) and the Android app (version 2.10.0 per the in -app about screen but the play store app says 2.12.8?)

1 Like

By “silently truncated”, does the command get fully pasted in the background or is it a hard cutoff that doesn’t allow any commands to exceed a length of 4095 bytes?

1 Like
1 Like