Skip to content

ls: measure the rendered directory header for dired offsets - #14656

Merged
sylvestre merged 1 commit into
uutils:mainfrom
ChihweiLHBird:zhiwei/fix-ls-dired-header-offsets
Sep 18, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
ChihweiLHBird:zhiwei/fix-ls-dired-header-offsets

Conversation

@ChihweiLHBird

@ChihweiLHBird ChihweiLHBird commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

--dired offsets must delimit the exact bytes written. write_dir_header measured directory headers by their raw path length, while show_dir_name prints them quoted according to the quoting style in force, so any quoting that lengthens a header (-Q, --quoting-style=shell-escape, a name with a space) cut its //SUBDIRED// entry short and shifted every later //DIRED// offset. show_dir_name now returns the rendered byte length and the bookkeeping uses that. Split out of #14590.

Example

mkdir 'a b' && touch 'a b/x'
ls --dired -R --quoting-style=shell-escape 'a b'

Before: the header is printed as 'a b' (5 bytes) but counted as a b (3 bytes), so //SUBDIRED// 2 5 covers 'a and //DIRED// 62 63 lands on the 0 of the size column instead of x.

  'a b':
  total 0
  -rw-r--r--+ 1 zhiwei zhiwei 0 Sep 17 19:20 x
//DIRED// 62 63
//SUBDIRED// 2 5
//DIRED-OPTIONS// --quoting-style=shell-escape-show-control

After: //SUBDIRED// 2 7 covers 'a b' and //DIRED// 64 65 covers x, the same offsets GNU prints.

  'a b':
  total 0
  -rw-r--r--+ 1 zhiwei zhiwei 0 Sep 17 19:20 x
//DIRED// 64 65
//SUBDIRED// 2 7
//DIRED-OPTIONS// --quoting-style=shell-escape-show-control

@ChihweiLHBird
ChihweiLHBird marked this pull request as ready for review September 17, 2026 19:13
@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
@ChihweiLHBird
ChihweiLHBird force-pushed the zhiwei/fix-ls-dired-header-offsets branch from e2bafe0 to 7e07b8e Compare September 18, 2026 21:37
@sylvestre
sylvestre enabled auto-merge (rebase) September 18, 2026 22:10
@sylvestre
sylvestre merged commit a3b3a24 into uutils:main Sep 18, 2026
103 checks passed
@ChihweiLHBird
ChihweiLHBird deleted the zhiwei/fix-ls-dired-header-offsets branch September 18, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants