Commit Graph
312 Commits
Author SHA1 Message Date
Guillem L. JaraandDaniel Hofstetter f774940451 fix(ls): place dot dirs on top in version sorting
Also fixes the fact that version sorting had incorrect edge cases due to wrong name passing.
2026-05-01 15:09:49 +02:00
oech3andGitHub 3f6a73da62 test_ls.rs: remove unsafe (#12044) 2026-04-28 00:10:49 +02:00
oech3andDaniel Hofstetter 2f49d8eb02 ls: use cfg unix 2026-04-23 10:15:38 +02:00
Sylvestre LedruandGitHub fd781df60a ls: restore WASI ".." metadata fallback in collect_directory_entries (#11930)
* ls: restore WASI ".." metadata fallback in collect_directory_entries

The ls refactor in #9851 dropped the WASI guard added in #11633, so
`ls -al` at a preopened root once again fails with "Capabilities
insufficient" when stat'ing "..". Extract the logic into a small
`dotdot_path` helper and add a regression test covering `ls -al`.

* Update spell-checker ignore words in test_ls.rs
2026-04-22 14:07:02 +02:00
oech3andGitHub ec1fcdb4ac ls, stty: reduce cfg by target_vendor (#11910) 2026-04-20 08:36:32 +02:00
ceb09c7014 ls: allow crate users to call ls without having to print everything to stdout (#9851)
* refactor uu_ls so that crate users can call the command without having
the internal print stdout output

* redo changes

* clippy

* help cspell understand dired

* rebase

* try and optimize for memory and speed performance.

update output handling to add streaming mode.

* work on ci issues, optimize uid and gid cache handling, improve dired output calculations

* test fx: change read_dir parameter to mutable reference in collect_directory_entries and enter_directory functions

* update documentation

* more perf tweaks

* fmt

* tweak perf

* Add back (and shorten) comment for 31_556_952

* Update src/uu/ls/src/ls.rs

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>

* Update src/uu/ls/src/ls.rs

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2026-04-17 14:26:23 +02:00
Sylvestre Ledru 6b044bb0d5 ls: fix link-count column inflating per ACL file
The `+1` accounting for the ACL/context indicator was applied once per
item inside the padding loop, so N files with ACLs inflated the
link-count column width by N. Apply it a single time after the loop.

Fixes #10980
2026-04-14 22:15:23 +02:00
Sylvestre LedruandDorian Péron 32cf4cdf0c du, ls: add integration tests for block size env var behavior 2026-04-07 13:01:43 +02:00
Sylvestre LedruandGitHub 8c100daa66 ls: fall back to "." metadata for ".." on WASI (#11633)
* ls: fall back to "." metadata for ".." on WASI

On WASI the sandbox blocks access to the parent directory at the
preopened root, causing ls -a to show an error and display ".."
with question marks. Fall back to the current directory metadata
so the entry appears with valid information.
2026-04-04 22:21:07 +02:00
oech3andDaniel Hofstetter 93157b7ebe ls: Fix error message for ls file/missing-file 2026-03-30 10:29:13 +02:00
aweinstock 85c9f25c35 ls: Treat paths starting with a dot as hidden even if they contain invalid UTF-8. 2026-02-26 18:25:03 -05:00
mattsuandGitHub eea061db56 ls:fix ls dired reports (#10527)
* refactor: simplify DisplayItemName struct and improve dired position handling

This commit refactors the `display_item_name` function to return a `DisplayItemName` struct containing both the displayed name and its dired length, rather than just the OsString. This change simplifies the code by:

1. Eliminating the need to call `dired_name_len()` separately after getting the displayed name
2. Reducing redundant length calculations in the dired position handling
3. Making the code more maintainable by encapsulating related data together

The change also fixes an issue where dired positions were being calculated incorrectly for symlink names that required quoting, ensuring proper highlighting in dired mode.

Closes: #10248
2026-02-14 10:50:11 +01:00
Chris DrydenandGitHub 57043cbb63 ls: release directory fds before recursing to avoid EMFILE - 12x mem improv (#10894) 2026-02-12 20:46:47 +01:00
Sylvestre LedruandGitHub c200e3b9e8 ls: fix hyperlink functionality to use correct OSC 8 format and handle symlink targets (#10824) 2026-02-09 17:36:28 -05:00
Yuri AstrakhanandGitHub 05204864d6 refactor: inline format! args in a few places (#10730)
* refactor: inline format! args in a few places

* in one spot remove redundant mem alloc

* run clippy fix with mixed
2026-02-07 10:05:44 +01:00
Christopher DrydenandSylvestre Ledru 3efdb50543 ls: fix symlink target coloring for chains and extensions 2026-01-17 09:21:55 +01:00
kimono-koansandGitHub fd9157a338 ls: Proper alignment for capabilities and ACLs notifications (#8793)
Fixes: https://github.com/uutils/coreutils/issues/8792
2026-01-14 12:00:12 +01:00
Beat Küng 04256acc75 Merge remote-tracking branch 'origin/main' into fix_ls_color_capability 2026-01-10 10:17:03 +01:00
karanabeandSylvestre Ledru 3b0567bfc3 fix(ls): align LS_COLORS handling with GNU
Colors: make StyleManager rely on lscolors’ explicit-style
flags, avoid unnecessary metadata/stat probes, and ensure
ln=target, or=, mi= honor GNU coloring semantics.

Tests: update test_ls_color_norm expectations so the fi=
and fi=0 cases now match GNU ls output, ensuring the new
color handling is verified.
2026-01-08 14:22:36 +01:00
karanabeandSylvestre Ledru f0f5abc5b7 test: cover GNU dangling symlink cases
Add seven ls tests mirroring GNU tests/ls/ls-misc.pl
sl-dangle3..9 to validate combinations of `ln=`, `or=` and `mi=`
settings. The tests verify both file-level output and directory
listings, including the `\x1b[m` reset requirement when `or=:` is
set.
Adjust existing Rust tests to GNU output.
Existing color tests were updated to match GNU output.
2026-01-08 14:22:36 +01:00
Sylvestre LedruandGitHub 0950081d08 Merge branch 'main' into fix_ls_color_capability 2025-12-29 14:26:33 +01:00
Vikram KangotraandGitHub df959b7e00 Merge pull request #9410 from vikram-kangotra/fix/ls-proc-self-fd-regression
ls: prevent ReadDir from closing before entries are processed
2025-11-26 23:15:04 +01:00
Adrian Kretz a58b1bea55 test/ls: add test to verify ACL from different dir 2025-10-27 21:46:34 +01:00
Beat Küng 20370d24a3 ls: fix color output in combination with capabilities
This includes the following fixes:
- style_for_indicator uses fallbacks in case ca= is not defined in
  LS_COLORS. This led to the normal file style being used, even if there
  was a more specific one. The fix is to use has_color_for instead.
  There is also a new test for that case (a specific style for .txt).
- has_acl always returns true on a system with SELinux, as each file has
  an acl named "security.selinux".
  This adds a more specific method has_security_cap_acl that checks for an
  acl named "security.capability". This matches the behavior of GNU's ls.

These problems already existed when capability coloring was added in
9a97c18877.
2025-10-21 19:43:40 +02:00
Beat Küng e3dffb5b0a fix test_ls: remove test/dir/ prefix in test_ls_capabilities
The output of 'ls test/cap_pos test/dir' looks like this:
test/cap_pos

test/dir:
cap_neg
cap_pos
2025-10-20 18:05:02 +02:00