Commit graph

7963 commits

Author SHA1 Message Date
Sylvestre Ledru
7e3b8f14d2
Merge pull request #7723 from cakebaker/cargo_toml_use_authors_workspace
Cargo.toml: use `authors.workspace = true`
2025-04-11 03:55:52 -04:00
Sylvestre Ledru
b13ce98484
Merge pull request #7699 from nyurik/returns
chore: simplify `return` in multi-branch
2025-04-11 03:53:10 -04:00
Yuri Astrakhan
b09cd32534 chore: clean up a few code paths
* `cp`: in `copy_dir.rs`, remove duplicate copy_file() calls and streamline error handling
* `install`: simplify `preserve_timestamp`
* `tee` - simplify error handling
2025-04-11 02:02:32 -04:00
Daniel Hofstetter
b366b68505 libstdbuf/Cargo.toml: move package entries 2025-04-11 07:15:55 +02:00
Daniel Hofstetter
83221201cc Cargo.toml: use "authors.workspace = true" 2025-04-11 06:59:11 +02:00
Yuri Astrakhan
b5ed4a4acf chore: simplify return in multi-branch
It is usually easier to reason about the code if the return is used in one place rather than in every branch of the match or if statements.
2025-04-11 00:24:45 -04:00
Sylvestre Ledru
5bfbc30fba
Merge pull request #7715 from nyurik/unused_qualifications
Enable and fix `unused_qualifications` lint
2025-04-10 18:11:08 -04:00
Yuri Astrakhan
76b1b6835c rm ptr::NonNull 2025-04-10 17:13:18 -04:00
Yuri Astrakhan
9f56bf5f07 Enable and fix unused_qualifications lint
Improve code readability
2025-04-10 16:54:18 -04:00
Yuri Astrakhan
895b208391 Consolidate crate config in workspace
Make all common data like version, edition, license, ... be managed in one central workspace. This makes management much simpler
2025-04-10 16:52:01 -04:00
hz2
cd2b56ea9c
cp: fix update prompting (#7668)
* added logic to check if we are updating the file and the destination is newer, to skip copying

* corrected logic to handle cp update

* - added test case that mocks the issue described in #7660
- adjusted conditions to satisfy clippy

* typo

* Update src/uu/cp/src/cp.rs

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

* Update tests/by-util/test_cp.rs

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

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2025-04-10 19:00:39 +02:00
Sylvestre Ledru
45c978fae6
Merge pull request #7686 from dan-hipschman/numfmt/add-zero-terminated-option
numfmt: add --zero-terminated option
2025-04-10 07:14:35 -04:00
Sylvestre Ledru
a89fc48388
Merge pull request #7656 from eduardorittner/main
printf: make negative values wrap around with unsigned/hex format
2025-04-10 06:48:50 -04:00
Sylvestre Ledru
eca400fcf3
Merge pull request #7689 from nyurik/inline2
chore: manual inline formatting
2025-04-10 06:42:01 -04:00
Daniel Hofstetter
b5df331170 uucore: add chrono to uptime feature 2025-04-10 10:59:27 +02:00
Sylvestre Ledru
64cf3f5dae
Merge pull request #7712 from drinkcat/parse_number_large_hex-fix
uucore: num_parser: Limit precision when computing 2**exp
2025-04-10 04:29:12 -04:00
Sylvestre Ledru
bf9a8b83f8
Merge pull request #7673 from lewisboon/df-thiserror
df: migrate OptionsError to thiserror
2025-04-09 21:11:49 -04:00
Lewis Boon
59d0e50397 df: migrate OptionsError to thiserror
Closes #7536
2025-04-09 22:32:45 +01:00
Yuri Astrakhan
2d95850700 chore: manual inline formatting
Minor manual cleanup - inlined many format args.  This makes the code a bit more readable, and helps spot a few inefficiencies and possible bugs.  Note that `&foo` in a `format!` parameter results in a 6% extra performance cost, and does not get inlined by the compiler (yet).
2025-04-09 15:33:46 -04:00
Nicolas Boichat
4a13f4d14b uucore: num_parser: Limit precision when computing 2**exp
The number of digits would grow exponentially when large exponents
are passed, leading to conversion of numbers like 0x2p1000000 taking
forever to compute.

We use exponentiation by squaring to keep the precision within
reasonable bounds.

Fixes #7708.
2025-04-09 15:29:57 +02:00
MidnightRocket
32fed17969
mktemp: Prevent race condition when setting permissions for tempdir
This prevents a race conditions vulnerability in the tempdir implementation, where an attacker
potentially could modify the created temporary directory, before the restrictive permissions are
set.

The race conditions occurs in the moment between the temporary directory is created, and the proper
permissions are set.

 # The fix

This patch changes the `make_temp_dir` to create the temporary directory with the proper
permissions creation time. Rather than first create, then set permissions.
This is done by giving the permissions to the builder.
See [tempfile doc](95540ed3fc/src/lib.rs (L449-L450)).

 # Severity Low

The attack is only possible if the umask is configured to allow writes by group or other for created
file/directories.

 # Related Resources

See: https://cwe.mitre.org/data/definitions/377.html
2025-04-09 11:18:09 +02:00
Daniel Hofstetter
ed8689eaa3
Merge pull request #7700 from nyurik/parens
chore: remove unneeded parens
2025-04-09 11:03:10 +02:00
Yuri Astrakhan
2413dc9168 Consolidate lint management with workspaces
At the moment, most crates rely on build scripts and other methods to keep lint-consistency. As of recent, Rust can use workspaces to globally set all the lint configurations.

This PR only adds lint configuration to each crate, but it does not introduce any changes to the code or lint configuration. In the subsequent PRs, I plan to gradually move lints from `uucore` to workspace, making all code consistent.

Note that `seq` relies on a custom lint config - which means its configuration may need to be managed by hand until Cargo introduces per-crate overrides.
2025-04-09 03:58:46 -04:00
Yuri Astrakhan
8b35439574 Address new clippy lints
Ran `cargo clippy --all-targets --workspace` and fixed a few minor issues
2025-04-09 01:10:01 -04:00
Yuri Astrakhan
170831ed2b chore: remove unneeded parens
Keeps code a bit more readable
2025-04-08 18:19:03 -04:00
Sylvestre Ledru
6ea1f5247f
Merge pull request #7703 from nyurik/lints
feat: minor linting
2025-04-08 17:16:42 -04:00
Sylvestre Ledru
1abe65cfdb
Merge pull request #7696 from nyurik/id-fix
bug: fix id printing of egid
2025-04-08 17:01:31 -04:00
Sylvestre Ledru
0a99ab86e9
Merge pull request #7698 from nyurik/assert-eq
chore: use `assert_eq!` and `assert_ne!` instead of `assert!`
2025-04-08 17:00:58 -04:00
Yuri Astrakhan
249ef537fe feat: minor linting 2025-04-08 16:34:21 -04:00
Terts Diepraam
8040305715
Merge pull request #7622 from blyxxyz/flush-bufwriters
Flush `BufWriter`s, clean up error reporting
2025-04-08 20:52:51 +02:00
Yuri Astrakhan
a27880e8a3 chore: use assert_eq! and assert_ne! instead of assert!
Makes intent clearer, and if something fails, prints the values that caused the failure as part of the panic message.
2025-04-08 13:25:41 -04:00
Dan Hipschman
81911f9f6a numfmt: add --zero-terminated option 2025-04-08 10:05:26 -07:00
Yuri Astrakhan
a207f997a3 bug: fix id printing of egid
Spotted while doing format arg inlining, and confirmed in https://github.com/uutils/coreutils/pull/7689#issuecomment-2786827777
2025-04-08 12:19:44 -04:00
Daniel Hofstetter
7f8ad6a32c
Merge pull request #7688 from nyurik/fmt-inline
chore: use inline formatting
2025-04-08 09:31:17 +02:00
Yuri Astrakhan
3dc771924c chore: cleanup trailing commas before parens
Deleted commas in cases like `foo,)` -- mostly in macros
2025-04-08 00:33:58 -04:00
Yuri Astrakhan
47b10539d0 chore: use inline formatting
Minor cleanup using clippy autofix.  This makes the code a bit more readable, and helps spot a few inefficiencies and possible bugs.

```
cargo clippy --fix --workspace -- -A clippy::all -W clippy::uninlined_format_args && cargo fmt
```
2025-04-07 22:56:21 -04:00
Clifford Ressel
b7bf8c9467
chmod: Correct chmod -R on dangling symlink and tests (#7618)
* Correct chmod -R on dangling symlink and tests

* Add tests of arg-level symlink to chmod

* Add tests of all symlink flag combos on chmod dangling

* Fix no traverse on dangling symlink

* Add chmod recursive tests of default symlink method

* Add default chmod -H flag tests

* Set chmod default traversal method correctly to -H

* Fix arg symlink chmod case

* Remove extra chmod -H testing

---------

Co-authored-by: Clifford Ressel <EMAIL@gmail.com>
2025-04-07 16:18:00 +02:00
eduardorittner
36ef5010e3 printf: make negative values wrap around with unsigned/hex format
To convert from negative to unsigned with overflow, we get the two's complement
representation of the absolute (unsigned) value.
2025-04-06 18:58:56 -03:00
Lewis Boon
36e7b28426 df: migrate OptionsError to thiserror
Closed #7536
2025-04-05 23:11:10 +01:00
Karl McDowall
b264457c41 tail: Performace improvements
Improve performance of `tail` utility. Tail now uses
performance-optimized memchr APIs when searching through a
file for delimiters.
2025-04-05 12:16:49 -06:00
Sylvestre Ledru
3971bb3b0c
Merge pull request #7620 from sargas/pass-printf-test
printf: Consistently handle negative widths/precision
2025-04-05 10:49:54 +02:00
Joseph Jon Booker
64ce76bdf1 uucore/format: add docs and tests for resolve_astrick_ methods 2025-04-05 02:02:33 -05:00
Joseph Jon Booker
95e5396c4c printf: Consistently handle negative widths/precision
Also allows character constants with " instead of ', and for
interpolated values with %b to use \0XXX notation for octal bytes
2025-04-05 02:02:31 -05:00
Karl McDowall
c56489e2b3 cat: Performance improvement when printing line numbers
Add a simple class to manually maintain a string representation
of the line number for the `cat` application.
Maintaing this string is much faster than converting a `usize`
line-number variable to a string each time it's needed.

Gives a significant performance improvement with -n and -b
flags.
2025-04-04 19:50:05 -06:00
karlmcdowall
e6ff6d5c69
cat: Formatting performance improvement (#7642)
* cat: Formatting performance improvement

Use memchr library in `cat` to improve performance when detecting
newlines.
Significantly improves performance when running with -n, -s, -E, -b
flags.


Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2025-04-04 23:47:28 +02:00
Sylvestre Ledru
88cf66174f
Merge pull request #7648 from drinkcat/parse_time-ebd
timeout: Use common parser to parse time duration
2025-04-04 23:46:48 +02:00
Sylvestre Ledru
295628a2e9
Merge pull request #7631 from drinkcat/format-hex-default
uucore: format: Fix hexadecimal default format print
2025-04-04 23:44:35 +02:00
Dorian Peron
273a0500d8 uucore: remove clap dev dependency as it is already mentionned in regular dependencies 2025-04-04 18:53:35 +02:00
Dorian Peron
a3f770fbe8 uucore: make glob dependence optional under the parser feature 2025-04-04 18:53:35 +02:00
Dorian Peron
9dd8d8ab0d uucore: make chrono, chrono-tz, iana-time-zone deps optional under the custom-tz-fmt feature 2025-04-04 18:53:35 +02:00