Commit graph

8748 commits

Author SHA1 Message Date
Sylvestre Ledru
2063aa1009 clap: improve the clap support + add tests 2025-08-14 10:52:03 +02:00
Sylvestre Ledru
c7342a939b clap: override the usage section 2025-08-14 10:52:03 +02:00
Sylvestre Ledru
f1beeb904c clap localization: address PR review comments
- Make colorize() function private since only used internally
  - Remove redundant colors_enabled checks
  - Add apply_color helper closure to reduce code duplication
  - Remove try_ prefix from function names for consistency
  - Update all utilities to use renamed functions
  - Fix app variable reference in mv utility
2025-08-14 10:52:03 +02:00
Sylvestre Ledru
b06b1e4ea8 l10n: Migrate all utilities to use LocalizedCommand 2025-08-14 10:52:03 +02:00
Sylvestre Ledru
e455f770f9 l10n: Add LocalizedCommand trait for clap localization 2025-08-14 10:52:03 +02:00
Daniel Hofstetter
78235182cc chmod: remove Windows function & unnecessary cfgs 2025-08-10 14:54:23 +02:00
Sylvestre Ledru
21c8e42c8f chmod: fix recursive symlink handling for -H/-L/-P flags (Closes: #8422) 2025-08-09 17:34:52 +02:00
Nicolas Boichat
d535824d86
Merge pull request #8442 from sylvestre/tr-perf
Improve tr performances (Closes: #8439)
2025-08-09 13:22:00 +08:00
Nicolas Boichat
620360a1e1
Merge pull request #8449 from sylvestre/issue-8407
Some checks are pending
CICD / Build/stable (push) Blocked by required conditions
CICD / Build/nightly (push) Blocked by required conditions
CICD / Binary sizes (push) Blocked by required conditions
CICD / Build (push) Blocked by required conditions
CICD / Tests/BusyBox test suite (push) Blocked by required conditions
CICD / Test all features separately (push) Blocked by required conditions
CICD / Build/SELinux (push) Blocked by required conditions
CICD / Tests/Toybox test suite (push) Blocked by required conditions
CICD / Code Coverage (push) Waiting to run
CICD / Separate Builds (push) Waiting to run
GnuTests / Run GNU tests (native) (push) Waiting to run
GnuTests / Run GNU tests (SELinux) (push) Waiting to run
Code Quality / Pre-commit hooks (push) Waiting to run
Code Quality / Style/format (push) Waiting to run
Code Quality / Style/lint (push) Waiting to run
Code Quality / Style/spelling (push) Waiting to run
Code Quality / Style/toml (push) Waiting to run
Code Quality / Style/Python (push) Waiting to run
GnuTests / Aggregate GNU test results (push) Blocked by required conditions
Android / Test builds (push) Waiting to run
FreeBSD / Style and Lint (push) Waiting to run
FreeBSD / Tests (push) Waiting to run
L10n (Localization) / L10n/Build and Test (push) Waiting to run
L10n (Localization) / L10n/Fluent Syntax Check (push) Waiting to run
L10n (Localization) / L10n/French Integration Test (push) Waiting to run
L10n (Localization) / L10n/Multi-call Binary Install Test (push) Waiting to run
L10n (Localization) / L10n/Installation Test (Make & Cargo) (push) Waiting to run
L10n (Localization) / L10n/Locale Support Verification (push) Waiting to run
L10n (Localization) / L10n/Locale Embedding Regression Test (push) Waiting to run
WSL2 / Test (push) Waiting to run
cp: fix directory permission preservation for sibling directories with -a (Closes: #8407)
2025-08-09 12:33:56 +08:00
Sylvestre Ledru
e7fdeb36ff tr: document how to bench its perf 2025-08-08 22:10:03 +02:00
Sylvestre Ledru
54959f3f6a tr: improve performances (Closes: #8439) 2025-08-08 22:10:03 +02:00
yuankunzhang
de77fc9296 mktemp: allow empty string arguments for -p/--tmpdir options 2025-08-08 14:30:06 +02:00
Sylvestre Ledru
302f08266a cp: fix directory permission preservation for sibling directories with -a (Closes: #8407) 2025-08-07 22:50:50 +02:00
Daniel Hofstetter
10dbffa466 od: allow function pointer comparisons
to suppress warnings from unpredictable_function_pointer_comparisons
lint
2025-08-07 16:42:21 +02:00
Daniel Hofstetter
ca20549477 clippy: fix warnings from cloned_ref_to_slice_refs 2025-08-07 16:42:21 +02:00
Daniel Hofstetter
45cd3e8e56 clippy: fix warnings from unnecessary_unwrap lint 2025-08-07 16:42:21 +02:00
Daniel Hofstetter
454bdcb039 clippy: fix warnings from manual_let_else lint 2025-08-07 16:12:03 +02:00
Daniel Hofstetter
49e4eba078 clippy: fix warnings from needless_return lint 2025-08-07 16:12:03 +02:00
Daniel Hofstetter
30f300c52b clippy: fix "hiding a lifetime" warnings
from mismatched_lifetime_syntaxes lint
2025-08-07 16:12:03 +02:00
Nicolas Boichat
f7f3bbc7f6 uucore: num_format: Optimize format_float_shortest
We already know the String length ahead of time, and we can
avoid using `format`.

Saves about ~30% performance on:
```
{seq} -f "%g" 0 1e-9 1e-3
```
2025-08-07 15:31:57 +08:00
Nicolas Boichat
e94793f9a1 uucore: num_format: Reduce calls to with_prec
with_prec is actually really expensive, so it's much better to
just call it once, and handle the rounding corner case manually.

Saves about ~20% performance on:
```
{seq} -f "%g" 0 1e-9 1e-3
```
2025-08-07 15:31:57 +08:00
Nicolas Boichat
f5e8609163 uucore: num_format: Move common scientific formatting code to a function
Both format_float_scientific and format_float_shortest carry the
same code, moving it to a single function will make it possible
to optimize both.
2025-08-07 14:29:21 +08:00
yuankunzhang
5825e5e346 mkfifo: support symbolic mode 2025-08-06 22:19:01 +08:00
Daniel Hofstetter
72a3ed4605
Merge pull request #8433 from drinkcat/od-f16-f32-width
Some checks are pending
CICD / Build/stable (push) Blocked by required conditions
CICD / Build/nightly (push) Blocked by required conditions
CICD / Binary sizes (push) Blocked by required conditions
CICD / Build (push) Blocked by required conditions
CICD / Tests/BusyBox test suite (push) Blocked by required conditions
CICD / Tests/Toybox test suite (push) Blocked by required conditions
CICD / Code Coverage (push) Waiting to run
CICD / Separate Builds (push) Waiting to run
CICD / Test all features separately (push) Blocked by required conditions
CICD / Build/SELinux (push) Blocked by required conditions
GnuTests / Run GNU tests (native) (push) Waiting to run
GnuTests / Run GNU tests (SELinux) (push) Waiting to run
GnuTests / Aggregate GNU test results (push) Blocked by required conditions
Android / Test builds (push) Waiting to run
Code Quality / Style/format (push) Waiting to run
Code Quality / Style/lint (push) Waiting to run
Code Quality / Style/spelling (push) Waiting to run
Code Quality / Style/toml (push) Waiting to run
Code Quality / Style/Python (push) Waiting to run
Code Quality / Pre-commit hooks (push) Waiting to run
FreeBSD / Style and Lint (push) Waiting to run
FreeBSD / Tests (push) Waiting to run
L10n (Localization) / L10n/Build and Test (push) Waiting to run
L10n (Localization) / L10n/Fluent Syntax Check (push) Waiting to run
L10n (Localization) / L10n/French Integration Test (push) Waiting to run
L10n (Localization) / L10n/Multi-call Binary Install Test (push) Waiting to run
L10n (Localization) / L10n/Installation Test (Make & Cargo) (push) Waiting to run
L10n (Localization) / L10n/Locale Support Verification (push) Waiting to run
L10n (Localization) / L10n/Locale Embedding Regression Test (push) Waiting to run
WSL2 / Test (push) Waiting to run
od: Switch f16 print to width=15/16, precision=8
2025-08-06 10:57:56 +02:00
Julian Andres Klode
c93b9ed6be tr: use an unbuffered stdout
Our stdin that we transform already is buffered (using 8192 byte
buffers in the previous commit), so avoid buffering our output
needlessly.

This effectively changes the code to write complete lines
immediately, for example, in

`( echo a; sleep 1 ) | tr a b`

we receive

    read(0, "a\n", 8192)                    = 2
    write(1, "b\n", 2)                      = 2
    read(0, "", 8192)                       = 0

instead of

    read(0, "a\n", 8192)                    = 2
    read(0, "", 8192)                       = 0
    write(1, "b\n", 2)                      = 2

which matches the GNU coreutils behavior.
2025-08-06 15:38:28 +08:00
Julian Andres Klode
ef40c472a3 tr: fix high memory use, possible heap exhaustion
Read the input into a statically sized buffer - 8192, matching
GNU - instead of reading until the end of the line, as reading
until the end of the line in a file with no end of line would
result in reading the entire file into memory.

Confusingly, GNU tr seems to write the 8192 byte in two chunks
of 1024 and 7168 byte, but I can't figure out why it would do
that; I don't see any line buffering in GNU tr.

Bug-Ubuntu: https://launchpad.net/bugs/2119520
2025-08-06 15:38:28 +08:00
Nicolas Boichat
991ba21510 od: Switch f16 print to width=15/16, precision=8
While I think precision=4 is enough to print f16 unambiguously,
being consistent with GNU implementation does not hurt.

Also, change width to 16 for f32 as well.

Fixes #8370.
2025-08-06 15:14:56 +08:00
Nicolas Boichat
fa24c8c595 hostname: *bsd: Collect lookup_host iterator into a vector
dns_lookup 2.1.0 turns the output of lookup_host into an opaque
iterator, collect it into a vector instead.

And since we're at it, improve error handling instead of just
unwrapping the result.
2025-08-06 15:11:53 +08:00
Sylvestre Ledru
6acfbf229d mv: move a string in fluent 2025-08-05 13:12:38 +02:00
Nicolas Boichat
6eff5c9aee uucore: locale: Fix clippy warning 2025-08-05 13:24:01 +08:00
Daniel Hofstetter
4e311ed89b
Merge pull request #8423 from sylvestre/en-embedded
Some checks are pending
CICD / Dependencies (push) Waiting to run
CICD / Build/Makefile (push) Blocked by required conditions
CICD / Build/stable (push) Blocked by required conditions
CICD / Build/nightly (push) Blocked by required conditions
CICD / Binary sizes (push) Blocked by required conditions
CICD / Tests/BusyBox test suite (push) Blocked by required conditions
CICD / Tests/Toybox test suite (push) Blocked by required conditions
CICD / Code Coverage (push) Waiting to run
CICD / Separate Builds (push) Waiting to run
CICD / Build/SELinux (push) Blocked by required conditions
GnuTests / Run GNU tests (native) (push) Waiting to run
GnuTests / Run GNU tests (SELinux) (push) Waiting to run
GnuTests / Aggregate GNU test results (push) Blocked by required conditions
Android / Test builds (push) Waiting to run
Code Quality / Style/Python (push) Waiting to run
Code Quality / Style/format (push) Waiting to run
Code Quality / Style/toml (push) Waiting to run
Code Quality / Style/lint (push) Waiting to run
Code Quality / Style/spelling (push) Waiting to run
Code Quality / Pre-commit hooks (push) Waiting to run
FreeBSD / Style and Lint (push) Waiting to run
FreeBSD / Tests (push) Waiting to run
L10n (Localization) / L10n/Locale Embedding Regression Test (push) Waiting to run
L10n (Localization) / L10n/Build and Test (push) Waiting to run
L10n (Localization) / L10n/Fluent Syntax Check (push) Waiting to run
L10n (Localization) / L10n/French Integration Test (push) Waiting to run
L10n (Localization) / L10n/Multi-call Binary Install Test (push) Waiting to run
L10n (Localization) / L10n/Installation Test (Make & Cargo) (push) Waiting to run
L10n (Localization) / L10n/Locale Support Verification (push) Waiting to run
WSL2 / Test (push) Waiting to run
l10n: embedded english strings + test the whole thing in github
2025-08-03 15:08:10 +02:00
Martin Kunkel
3b4b769976
tests: fix execution on WSL2, Ubuntu 24.04 (#8235)
* tests: fix execution on WSL2, Ubuntu 24.04

Skip incompatible parts of tests to ensure that
    cargo nextest run --features unix
executes successfully in WSL2, Ubuntu 24.04 distribution.

Changes
* Skip tests that required sys/kernel/profiling which is not
available in WSL2 default configuration.
* Use timezones in tests that are part of the standard tzdata
list and not only available in backwards list. Backwards list is
not installed by default in Ubuntu 24.04 (package tzdata-legacy).
* check that /proc/modules is not empty when expecting content,
because it is empty in WSL2 default configuration.
* Skip logname test not only in WSL1, also in WSL2.

* Add workflow for WSL2

This will setup WSL2 on windows-latest runner, install
Ubuntu-24.04, and run the feat_os_unix tests.

* wsl2: implemented review findings

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2025-08-03 14:38:49 +02:00
Sylvestre Ledru
df2fca588c l10n: when built indiv, only embed the relevant locale file 2025-08-03 10:59:38 +02:00
Sylvestre Ledru
a432fe811f l10n: use the embedded english strings when relevant 2025-08-03 10:59:38 +02:00
Daniel Hofstetter
9938db39bc
Merge pull request #8333 from sylvestre/selinux-mv
Some checks are pending
CICD / Style/cargo-deny (push) Waiting to run
CICD / Dependencies (push) Waiting to run
CICD / Style/deps (push) Waiting to run
CICD / Documentation/warnings (push) Waiting to run
CICD / MinRustV (push) Waiting to run
CICD / Test all features separately (push) Blocked by required conditions
CICD / Build/Makefile (push) Blocked by required conditions
CICD / Build/stable (push) Blocked by required conditions
CICD / Build/nightly (push) Blocked by required conditions
CICD / Binary sizes (push) Blocked by required conditions
CICD / Build (push) Blocked by required conditions
CICD / Tests/BusyBox test suite (push) Blocked by required conditions
CICD / Tests/Toybox test suite (push) Blocked by required conditions
CICD / Code Coverage (push) Waiting to run
CICD / Separate Builds (push) Waiting to run
CICD / Build/SELinux (push) Blocked by required conditions
GnuTests / Run GNU tests (native) (push) Waiting to run
GnuTests / Run GNU tests (SELinux) (push) Waiting to run
GnuTests / Aggregate GNU test results (push) Blocked by required conditions
Android / Test builds (push) Waiting to run
Code Quality / Style/toml (push) Waiting to run
Code Quality / Style/format (push) Waiting to run
Code Quality / Style/Python (push) Waiting to run
Code Quality / Style/lint (push) Waiting to run
Code Quality / Style/spelling (push) Waiting to run
Code Quality / Pre-commit hooks (push) Waiting to run
FreeBSD / Style and Lint (push) Waiting to run
FreeBSD / Tests (push) Waiting to run
mv: add support for selinux and add minor refactor
2025-08-01 09:36:06 +02:00
Dorian Péron
d90f3a4ec3
Merge pull request #8416 from drinkcat/cp-attr
Some checks are pending
CICD / Build (push) Blocked by required conditions
CICD / Style/cargo-deny (push) Waiting to run
CICD / Style/deps (push) Waiting to run
CICD / Test all features separately (push) Blocked by required conditions
CICD / Documentation/warnings (push) Waiting to run
CICD / MinRustV (push) Waiting to run
CICD / Dependencies (push) Waiting to run
CICD / Build/Makefile (push) Blocked by required conditions
CICD / Build/stable (push) Blocked by required conditions
CICD / Build/nightly (push) Blocked by required conditions
CICD / Binary sizes (push) Blocked by required conditions
CICD / Tests/BusyBox test suite (push) Blocked by required conditions
CICD / Tests/Toybox test suite (push) Blocked by required conditions
CICD / Code Coverage (push) Waiting to run
CICD / Separate Builds (push) Waiting to run
CICD / Build/SELinux (push) Blocked by required conditions
GnuTests / Run GNU tests (native) (push) Waiting to run
GnuTests / Run GNU tests (SELinux) (push) Waiting to run
GnuTests / Aggregate GNU test results (push) Blocked by required conditions
Android / Test builds (push) Waiting to run
Code Quality / Style/format (push) Waiting to run
Code Quality / Style/lint (push) Waiting to run
Code Quality / Style/spelling (push) Waiting to run
Code Quality / Style/toml (push) Waiting to run
Code Quality / Style/Python (push) Waiting to run
Code Quality / Pre-commit hooks (push) Waiting to run
FreeBSD / Style and Lint (push) Waiting to run
FreeBSD / Tests (push) Waiting to run
`cp`: Properly preserves fifos and symlink attributes
2025-07-31 18:04:17 +02:00
Sylvestre Ledru
6e930966fb selinux: introduce get_getfattr_output to verify the output of getfatt 2025-07-31 17:45:34 +02:00
Sylvestre Ledru
ad8fdbdb77 mv: implement selinux options (-Z/--context) 2025-07-31 17:45:34 +02:00
Daniel Hofstetter
7003b1d3fc
Merge pull request #8418 from drinkcat/pr-time
pr: Add support for -D/--date-format parameter
2025-07-31 16:34:44 +02:00
Nicolas Boichat
bdedd24e06
pr: Move vector creation
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2025-07-31 22:05:35 +08:00
Daniel Hofstetter
b5f453a562
Merge pull request #8417 from drinkcat/du-ls-time-test
ls: -u/-c/--time control sorting when -l is not used
2025-07-31 15:55:40 +02:00
Daniel Hofstetter
194aa89d63 rm: implement From for InteractiveMode 2025-07-31 09:49:27 +02:00
Daniel Hofstetter
f33244321a rm: use clap to handle --interactive args 2025-07-31 09:49:05 +02:00
Nicolas Boichat
d35a60e5e2 pr: Add support for -D/--date-format parameter 2025-07-31 15:45:31 +08:00
Nicolas Boichat
4878e65ea7 pr: Set date format depending on environment.
Based on GNU manual.
2025-07-31 15:45:31 +08:00
Nicolas Boichat
149529a494 pr: Switch to uucore::time formatting 2025-07-31 15:45:31 +08:00
Nicolas Boichat
ec11b68543 ls: -u/-c/--time control sorting when -l is not used
Fallback on those flags if --sort is not otherwise set.
2025-07-31 09:00:15 +02:00
Nicolas Boichat
4b11692db3 cp: Also copy attributes in copy_symlink
Most attributes can actually be applied to symlinks (mode and
xattr are exceptions), so try to copy them, if possible.

Fort those 2 exceptions, we don't need any special handling as:
 - Mode errors would be ignored anyway.
 - The source symlink cannot have any xattr anyway, so no
   attribute is attempted to be set on the destination.
2025-07-30 20:03:22 +08:00
Nicolas Boichat
4cb57fb7ac ls: cleanup imports
They were a bit jumbled with no particular logic, at least that
I could see.
2025-07-30 17:59:52 +08:00
Nicolas Boichat
4ba8d3e0a9 ls: Fix Windows build 2025-07-30 17:58:39 +08:00