There was quite a bunch of different features missing in timeout, to start off, now that we have a mechanism to read the SIGPIPE handlers before they are overwritten by the rust runtime, it means that we can not propagate this signal down to the child processes if the signal is set to ignore.
This also includes all of the latest changes since 9.9 where the specific signal sent to timeout will be propagated instead of just defaulting to a TERM signal.
Implements era year calculation for Buddhist, Persian Solar Hijri, and Ethiopian calendars based on locale detection. The %Y format specifier now outputs era-appropriate years while maintaining Gregorian calendar for ISO-8601 and RFC-3339 formats for interoperability.
This adds a new option to get reproducible output from a seed. This
was already possible with --random-source, but doing that properly was
tricky and had poor performance.
Adding this option implies a commitment to keep using the exact same
algorithms in the future. For that reason we only use third-party
libraries for well-known algorithms and implement our own
distributions on top of that.
-----
As a teenager on King's Day I once used `shuf` for divination. People
paid €0.50 to enter a cramped tent and sat down next to me behind an
old netbook. I would ask their name and their sun sign and pipe this
information into `shuf --random-source=/dev/stdin`, which selected
pseudo-random dictionary words and `tee`d them into `espeak`.
If someone's name was too short `shuf` crashed with an end of file
error. --random-seed would have worked better.
When the --random-source option is used uutils shuf now gives
identical output to GNU shuf in many (but not all) cases. This is
helpful to users who use it to get deterministic output, e.g. by
combining it with `openssl` as suggested in the GNU info pages.
I reverse engineered the algorithm from GNU shuf's output. There may
be bugs.
Other modes of shuffling still use `rand`'s `ThreadRng`, though they
now sample a uniform distribution directly without going through the
slice helper trait.
Additionally, switch from `usize` to `u64` for `--input-range` and
`--head-count`. This way the same range of numbers can be generated on
32-bit platforms as on 64-bit platforms.
This gives a 1.8× speedup over a stdlib formatted write for
`shuf -r -n1000000 -i1-1024`.
The original version of this commit replaced a formatted write, but
before it got merged main received optimized manual formatting from
another PR. The speedup of itoa over the manual write is around 1.1×,
much less dramatic.
* cp/mv: suppress xattr ENOTSUP errors for optional preservation
* mv: copy xattrs for symlink fallback and format tests
* cp: fix test expectation for GNU-compatible error format
* fix test portability for Android and xattr detection
---------
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
* tail: fix --pid with FIFO by using non-blocking open
* Address review comments: propagate fcntl errors and remove Windows stub
---------
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Sylvestre Ledru <sylvestre.ledru@gmail.com>
* wc: align SIMD policy integration
- use SimdPolicy::detect with hardware feature labeling
- keep SIMD behavior respecting GLIBC_TUNABLES
- consolidate wc SIMD debug output and tests
* refactor(wc): simplify SIMD feature collection in debug output
- Changed multi-line SIMD feature vector creation to a single-line expression for improved readability and consistency with surrounding code.
- No functional changes; only stylistic refactoring in the wc debug logic.
* feat(wc): enhance debug output for SIMD hardware support limitations
Add new localization strings and logic to provide detailed debug information when SIMD support is limited by GLIBC_TUNABLES, including lists of disabled and enabled features. Refactor SIMD allowance check for better accuracy in detecting runtime support.
* refactor: consolidate SIMD feature handling in wc command
Refactor SIMD feature detection and reporting in the wc utility by introducing a WcSimdFeatures struct to group enabled, disabled, and runtime-disabled features. This replaces multiple separate functions with a single function, improving code organization and efficiency by reducing redundant iterations over feature lists. Also rename helper functions for clarity and update debug output logic accordingly.
* Update src/uu/wc/src/wc.rs
Co-authored-by: Dorian Péron <72708393+RenjiSann@users.noreply.github.com>
* Update src/uu/wc/locales/en-US.ftl
Co-authored-by: Dorian Péron <72708393+RenjiSann@users.noreply.github.com>
* Update src/uu/wc/locales/fr-FR.ftl
Co-authored-by: Dorian Péron <72708393+RenjiSann@users.noreply.github.com>
* feat(wc): import show_error for enhanced error reporting
Add the show_error import from uucore to enable better error handling in the wc utility, allowing for consistent error messages in line with the project's style.
---------
Co-authored-by: Dorian Péron <72708393+RenjiSann@users.noreply.github.com>
* stty: Add 101 unit tests and 16 integration tests to improve coverage
Add comprehensive test coverage for stty:
Unit tests (src/uu/stty/src/stty.rs):
- Flag struct methods and builder pattern (7 tests)
- Control character parsing and formatting (19 tests)
- All combination settings expansion (26 tests)
- Termios modification functions (13 tests)
- String-to-flag/combo/baud parsing (19 tests)
- TermiosFlag trait implementations (5 tests)
- Helper and utility functions (10 tests)
- Trait implementations (2 tests)
Integration tests (tests/by-util/test_stty.rs):
- Help and version output validation (2 tests)
- Invalid argument handling (3 tests)
- Control character overflow validation (2 tests)
- Grouped flag removal validation (1 test)
- File argument error handling (1 test)
- Conflicting print modes (1 test)
- Additional TTY-dependent tests (6 tests, ignored in CI)
Unit test coverage improved from 0% to 43.76% (207/473 lines).
Integration tests validate argument parsing and error handling.
Addresses #9061
* stty: Add essential unit tests and integration tests to improve coverage
- Added 11 essential unit tests for complex internal functions:
* Control character parsing (string_to_control_char)
* Control character formatting (control_char_to_string)
* Combination settings expansion (combo_to_flags)
* Terminal size parsing with overflow handling (parse_rows_cols)
* Sane control character defaults (get_sane_control_char)
- Added 16 integration tests for command behavior:
* Help/version output validation
* Invalid argument handling
* Control character overflow validation
* Grouped flag removal validation
* File argument error handling
* Conflicting print modes
* TTY-dependent tests (marked as ignored for CI)
Unit tests focus on complex parsing logic that's difficult to test via
integration tests. Integration tests validate actual command behavior.
Coverage improved from 0% to 43.76% (207/473 lines).
Fixes#9061
* stty: Add comprehensive unit and integration tests for error handling
- Add unit tests for parse_rows_cols() with edge cases and wraparound
- Add unit tests for string_to_baud() with platform-specific handling
- Add unit tests for string_to_combo() with all combo modes
- Add 17 integration tests for missing arguments and invalid inputs
- Enhance test_invalid_arg() with better error message assertions
- Update coverage script for improved reporting
Coverage improved from 22.26% to 23.14% regions.
* stty: Add Debug and PartialEq derives for test assertions
- Add #[derive(Debug, PartialEq)] to AllFlags enum
- Add PartialEq to Flag struct derives
- Enables assert_eq! macro usage in unit tests
* stty: Fix formatting and clippy warnings in tests
- Replace assert_eq! with assert! for boolean comparisons
- Fix line wrapping for long logical expressions
- Use inline format string syntax (e.g., {err} instead of {})
- All 25 unit tests pass
- No clippy warnings
* stty: Add inline spell-checker ignores for test strings
- Add spell-checker:ignore comments for test data (notachar, notabaud, susp)
- Add spell-checker:ignore comments for French error strings (Valeur, entier, invalide)
- Fixes cspell validation without modifying global config
* perf: gate PartialEq derive to test builds only
The PartialEq derive was being compiled into release builds even though
it's only used in test code. This caused a 3.33% performance regression
in the du_human_balanced_tree benchmark due to increased binary size
affecting CPU cache efficiency.
Changes:
- stty.rs: Gate PartialEq derive on Flag<T> with #[cfg_attr(test, derive(PartialEq))]
- flags.rs: Gate PartialEq derive on AllFlags enum with #[cfg_attr(test, derive(PartialEq))]
This eliminates the performance regression while keeping all test code
functional and unchanged.
---------
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>