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
[gap] trailing '/' on a regular file is silently stripped: readers accept it, tee/dd/cp/mv write through it (data loss), some errors report ENOENT or exit 0 #1052
A trailing / (or //, /.) on a pathname must force directory resolution: on a regular file GNU returns ENOTDIR; a nonexistent name/ is also ENOTDIR, not a createable file. WinuxCmd normalizes the separator away and proceeds, producing three symptom classes.
Test file: f2.txt = "line1\nline2\n" (12 bytes).
Class 1 — silently READS the file (GNU: Not a directory, rc=1/2)
winuxcmd.exe wc -l f2.txt/ -> 2 f2.txt/ rc=0 (GNU: wc: f2.txt/: Not a directory, rc=1)
winuxcmd.exe sort f2.txt/ -> prints contents rc=0 (GNU: Not a directory, rc=2)
winuxcmd.exe head/tail f2.txt/ -> prints contents rc=0
winuxcmd.exe grep x f2.txt/ -> matches rc=0
winuxcmd.exe od / nl / fold / cut / rev / fmt / pr f2.txt/ -> all read it, rc=0
winuxcmd.exe md5sum/sha1sum/sha256sum/sha512sum/b2sum/cksum/sum f2.txt/ -> hashes printed, rc=0
(note: sha1sum/sha512sum print the EMPTY-input hash da39a3ee../cf83e135.., md5sum/sha256sum print the real content hash)
winuxcmd.exe cmp f2.txt f2.txt/ -> rc=0 (identical!) (GNU: cmp: f2.txt/: Not a directory, rc=2)
winuxcmd.exe comm/join/paste f2.txt/ -> read it, rc=0
winuxcmd.exe split -l1 f2.txt/ -> creates xaa/xab rc=0 (GNU: cannot open ... Not a directory)
winuxcmd.exe df f2.txt/ -> prints D:\ volume info, rc=0 (GNU: df: f2.txt/: Not a directory, rc=1)
winuxcmd.exe realpath f2.txt/ -> prints D:\...\f2.txt\, rc=0 (GNU: realpath: f2.txt/: Not a directory, rc=1)
Class 2 — silently WRITES / creates files (GNU errors; potential data loss)
Follow-up: backslash separators behave identically — wc -c f2.txt\ reads the file (rc=0), cp f2.txt nodirz\ creates a regular file nodirz (rc=0). GNU treats trailing \ the same as /: wc: 'f2.txt\': Not a directory, cp: cannot create regular file 'nodirz\': Is a directory (note GNU reports EISDIR here, not ENOTDIR).
Root cause: path normalization silently stripped trailing separators, so tee file/, cp src file/ etc. opened the regular file and could truncate/overwrite it.
Fix: normalize_api_operand_w() keeps the separator when the stripped target is not a directory, so the OS rejects the operand. Shared helpers operand_target_attributes_w()/operand_file_open_error() classify the real target: ENOTDIR for read opens, EISDIR for write/create opens (matches the Linux O_CREAT quirk — GNU tee f/ reports "Is a directory"), ENOENT for missing targets. file_io helpers now return failbit-set streams; tee/cp surface the real error.
Verified: file content preserved, mkdir dir/ and cp src dir/ still work, 26 trailing-separator tests + 216 tests across touched commands pass.
Activity
caomengxuan666 commentedon Sep 14, 2026
Follow-up: backslash separators behave identically —
wc -c f2.txt\reads the file (rc=0),cp f2.txt nodirz\creates a regular filenodirz(rc=0). GNU treats trailing\the same as/:wc: 'f2.txt\': Not a directory,cp: cannot create regular file 'nodirz\': Is a directory(note GNU reports EISDIR here, not ENOTDIR).caomengxuan666 commentedon Sep 14, 2026
Fixed in 182b1de.
Root cause: path normalization silently stripped trailing separators, so
tee file/,cp src file/etc. opened the regular file and could truncate/overwrite it.Fix:
normalize_api_operand_w()keeps the separator when the stripped target is not a directory, so the OS rejects the operand. Shared helpersoperand_target_attributes_w()/operand_file_open_error()classify the real target: ENOTDIR for read opens, EISDIR for write/create opens (matches the Linux O_CREAT quirk — GNUtee f/reports "Is a directory"), ENOENT for missing targets. file_io helpers now return failbit-set streams; tee/cp surface the real error.Verified: file content preserved,
mkdir dir/andcp src dir/still work, 26 trailing-separator tests + 216 tests across touched commands pass.fix(path): reject trailing separators on non-directories (#1052)
fix(core): pseudo-device operands, closed-stdin detection, extended p…
fix(cpio): route archive and member paths through the operand boundar…
fix(cpio): route archive and member paths through the operand boundar…
fix(cpio): route archive and member paths through the operand boundar…
fix(cpio): route archive and member paths through the operand boundar…
fix(cpio): route archive and member paths through the operand boundar…
rust2 unlink: byte-match the 1.x Windows failure text for wiring gate c
feat(winux-core): port the shell-namespace path contract from 1.x nat…
feat(winux-core): port the shell-namespace path contract from 1.x nat…