You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
the 0x1A stdin truncation is not checksum-specific: 16 line/file applets read stdin in text mode; head gives three different answers #1202
The 0x1A stdin truncation is not checksum-specific (that is #1195 / #1200). Sixteen line/file applets read stdin in CRT text mode, so data after 0x1A is dropped and \r\n is collapsed — while the same command reading a file operand is correct. The command disagrees with itself.
Both the niu PATH path and the direct .exe are affected, so this is the applet, not the in-process fast path.
The cleanest single repro: head gives three different answers
Input created with python (not shell escapes): b"abc\x1adef\n".
form
bytes out
head f.bin (operand)
61 62 63 1a 64 65 66 0a
correct
head < f.bin
61 62 63
truncated at 0x1A
cat f.bin | head
61 62 63
truncated at 0x1A
GNU coreutils, all three forms
61 62 63 1a 64 65 66 0a
correct
Direct …\winuxcmd\usr\bin\head.exe produces the same two/one split. Output captured to files and compared with python (not with the in-tree od).
Known-correct reference points in the same tree: cat, tr, od, wc, base64 read binary stdin correctly, and the checksum family is already tracked (#1195, #1200).
Suggested root cause (from the sweep that found it; I have not read the source)
A shared line/file reader used by these applets should set stdin to binary (_O_BINARY / _setmode) once, rather than each command handling it. The already-correct commands above are the reference.
xxd -p also wraps at 32 hex chars per line instead of GNU's 60 — filed separately.
Method
Niubash 1.4.0, Windows 10 x64 (build 19045), winuxcmd 1.1.12; GNU coreutils via WSL; inputs written and outputs compared with python so neither shell escaping nor the in-tree od mediates the bytes.
The sixteen applets named here are fixed together with the rest of the class in #1218 (branch fix/stdin-binary-sweep), which adds file_io::set_stdin_binary() on each stdin route. See also the follow-up issue #1212.
a980ea6 fix(stdin): read fd 0 in binary mode across the remaining text-mode applets (#1202, #1212, #1211) (#1218) cites this issue by number, and the patch adds binary-mode stdin handling plus unit tests across the applet set (73 files changed — xxd, nl, paste, unexpand, uniq, sed, sort, tail, strings, …). src/utils/file_io.cppm now does _setmode(_fileno(stdin), _O_BINARY) on the shared read paths (lines 260/271).
Honest caveat on my verification: I could not build master on this machine (no Visual Studio / CMake here — the documented path is VS 2022 + CMake 3.30 + Ninja), so this is source-level plus your own added tests, not a runtime re-run by me. The build I originally reported against was 1.1.13 (fbdd2ff), which predates a980ea6 — my error, same class as the stale-build mistake I made on two brush reports.
If you want a runtime confirmation from me, point me at a published binary that includes a980ea6 and I will re-run the original probe (0x1A-truncation across the line/file applets) and report the raw bytes.
Activity
caomengxuan666 commentedon Oct 17, 2026
The sixteen applets named here are fixed together with the rest of the class in #1218 (branch
fix/stdin-binary-sweep), which addsfile_io::set_stdin_binary()on each stdin route. See also the follow-up issue #1212.fix(stdin): read fd 0 in binary mode across the remaining text-mode a…
caomengxuan666 commentedon Oct 17, 2026
Fixed on master — closing
a980ea6 fix(stdin): read fd 0 in binary mode across the remaining text-mode applets (#1202, #1212, #1211) (#1218)cites this issue by number, and the patch adds binary-mode stdin handling plus unit tests across the applet set (73 files changed —xxd,nl,paste,unexpand,uniq,sed,sort,tail,strings, …).src/utils/file_io.cppmnow does_setmode(_fileno(stdin), _O_BINARY)on the shared read paths (lines 260/271).Honest caveat on my verification: I could not build master on this machine (no Visual Studio / CMake here — the documented path is VS 2022 + CMake 3.30 + Ninja), so this is source-level plus your own added tests, not a runtime re-run by me. The build I originally reported against was
1.1.13(fbdd2ff), which predatesa980ea6— my error, same class as the stale-build mistake I made on two brush reports.If you want a runtime confirmation from me, point me at a published binary that includes
a980ea6and I will re-run the original probe (0x1A-truncation across the line/file applets) and report the raw bytes.