cat There is no limit to the length of text that can be read. And cat (the default parameter) doesn't care how many lines the file has; it just keeps copying the data.
The problem is with the linenoise library used by mongo shell. At <mongo>/shell/linenoise.cpp:2541 (different versions may differ), if the data is not obtained from the terminal, linenoise always fetches up to 4096 bytes per line (UTF-8), so mongo reads the broken lines (linsenoise simply Didn't consider it breaking some lines by doing so; maybe they simply didn't test it for non-interactive use).
As for reading from the terminal, it uses another set of logic. When I tried to put in a super long line of 4100 characters, it just kept blinking and blinking and nothing came of it. I don’t know if there is a problem with this part, but I can’t test it anyway. The questioner might try typing the super long line directly.
I tried readline (Python) and everything works fine, even very long lines can be entered relatively easily and parsed correctly. Of course, zsh and bash, which often read scripts from pipes, will handle these situations well.
cat
There is no limit to the length of text that can be read. Andcat
(the default parameter) doesn't care how many lines the file has; it just keeps copying the data.The problem is with the linenoise library used by mongo shell. At
<mongo>/shell/linenoise.cpp:2541
(different versions may differ), if the data is not obtained from the terminal, linenoise always fetches up to 4096 bytes per line (UTF-8), so mongo reads the broken lines (linsenoise simply Didn't consider it breaking some lines by doing so; maybe they simply didn't test it for non-interactive use).As for reading from the terminal, it uses another set of logic. When I tried to put in a super long line of 4100 characters, it just kept blinking and blinking and nothing came of it. I don’t know if there is a problem with this part, but I can’t test it anyway. The questioner might try typing the super long line directly.
I tried readline (Python) and everything works fine, even very long lines can be entered relatively easily and parsed correctly. Of course, zsh and bash, which often read scripts from pipes, will handle these situations well.