I'm the maintainer of a terminal emulator on Mac OS and a user
reported that if he pastes a large string of the form:

cat << EOF > whatever.txt
blah blah blah
blah blah blah
... etc for 100k ...
EOF

That the output is badly mangled. I can reproduce this consistently
with a smallish test program. Having traced into readline, the culprit
seems to be that readline fiddles with the terminal between lines of
input (I'm pretty sure the things done in set_tty_settings() are
responsible, but I haven't proved it yet). This seems to cause it to
drop some or all of the input that's in the input buffer.

Is this a known issue? I can reproduce it on Linux as well, but it's
much less severe. The test case can be found here:

http://pastebin.com/as3KjEcq

To build on Mac, compile with
gcc bug.c -o bug -DMACOS

To build on Linux:
gcc bug.c /usr/lib/libutil.a -o bug

It should produce a file in your home directory called mytestfile.txt
that looks like this:
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXY
ZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX
YZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW
etc.

On Linux, you get the occasional short line. On Mac OS, you get only a
few lines and they're very long.

I can reproduce this on Mac OS with the latest bash source build with
default settings.

Thanks for your help,
George

Reply via email to