Commit graph

4102 commits

Author SHA1 Message Date
Nicolas Boichat
2d63020cd9 du: Add support for reading time-style from environment
Similar as what ls does, but du has an extra compatibility layer
described in the GNU manual (and that upstream dev helped me
understand: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=79113 ).
2025-07-30 17:27:22 +08:00
Nicolas Boichat
1272bfc222 du: Add support for +FORMAT time-style
Also add to error text, which... GNU coreutils doesn't do for
some reason.
2025-07-30 17:27:22 +08:00
Nicolas Boichat
fc08fa1d62 ls: Print dates in the future as "old" ones
ls has different time format for recent (< 6 months) and older files.
Files in the future (even by just a second), are considered old,
which makes sense as we probably want the date to be printed in
that case.
2025-07-30 17:27:22 +08:00
Nicolas Boichat
4901f370cb ls: Add support for newline separated format for recent/older
Documented in GNU manual.

Also improve test_ls to test for both recent and older files.
2025-07-30 17:27:22 +08:00
Nicolas Boichat
e5f2f79ea1 ls: Allow reading time-style from TIME_STYLE environment variable
According to GNU manual.
2025-07-30 17:27:22 +08:00
Nicolas Boichat
a1519e1b74 ls: Add support for --time-style=posix-*
From GNU manual, if LC_TIME=POSIX, then the "locale" timestamp is
used. Else, `posix-` is stripped and the format is parsed as usual.

Also, just move the whole text to the locale file, instead
of trying to generate it manually.
2025-07-30 17:27:20 +08:00
Daniel Hofstetter
790852ff9a
Merge pull request #8403 from sylvestre/ls-others
ls: improve the test when running selinux
2025-07-29 12:51:54 +02:00
Julian Andres Klode
190ddd105c install: Fix --no-target-directory with existing file
install should silently override existing target files, but it
inadvertently checked whether the target exists rather than
for the target being a directory, hence the overwrite failed,
saying it cannot overwrite the directory with non-directory.

Bug-Ubuntu: https://bugs.launchpad.net/bugs/2118785
2025-07-29 12:24:31 +02:00
Jonas Jelten
79bbf52a21
Merge pull request #8343 from TheJJ/fix-mknod-mode
mknod: set cli specified file mode even when it's 0o666
2025-07-29 11:53:21 +02:00
Sylvestre Ledru
7e320a75d9 ls: improve the test when running selinux 2025-07-28 21:17:09 +02:00
Sylvestre Ledru
582c619b7e date: update deprecated TZ
See:
https://data.iana.org/time-zones/tzdb/backward
2025-07-28 21:13:54 +02:00
Nicolas Boichat
b8d81adcff du/test_du: Fix ctime fallback on Windows, and test 2025-07-27 12:57:28 +08:00
Nicolas Boichat
96438f2086 test_du: Fix --time=ctime test
It turns out `du` used to test for the wrong thing, `ctime` is
the change timestamp, not creation time.

We have to rely on a regex again, as the change timestamp is the
current time.
2025-07-27 10:57:07 +08:00
Dorian Peron
27faee711b test(sort): Fix fixtures 2025-07-25 13:51:53 +02:00
Dorian Peron
365f6a36fa test_util_name: ignore sort tests 2025-07-25 13:51:53 +02:00
Nicolas Boichat
6884e29f97 test_df: Use lossy stdout string
The tests fail when a non-UTF8 path is mounted, that's... not a
common case, but using a lossy string works just as well for the
tests, so let's use that.
2025-07-24 09:39:18 +08:00
Yonatan Linik
bd2e33bb34 sort: Support hexadecimal numbers/floats correctly
Some checks are pending
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 / 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 (push) Waiting to run
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
Fixes https://github.com/uutils/coreutils/issues/8060
2025-07-23 21:14:14 +02:00
Nicolas Boichat
22d474f275 test_basename: Fix test_invalid_utf8_args
The test was not really testing for the right thing. If a non-unicode
string is passed, the basename should be printed as-is.
2025-07-23 21:06:02 +08:00
Sylvestre Ledru
c5268a897e basename: handle a corner case with /. - Closes #8373 2025-07-23 13:53:34 +02:00
Daniel Hofstetter
8218f80bb0
Merge pull request #8367 from drinkcat/mkdir-osstr
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 / 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 / Test all features separately (push) Blocked by required conditions
CICD / Build/SELinux (push) Blocked by required conditions
GnuTests / Run GNU tests (push) Waiting to run
Android / Test builds (push) Waiting to run
Code Quality / Style/toml (push) Waiting to run
Code Quality / Style/Python (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 / Pre-commit hooks (push) Waiting to run
FreeBSD / Style and Lint (push) Waiting to run
FreeBSD / Tests (push) Waiting to run
Fix mkdir with non-unicode parameters
2025-07-22 17:15:19 +02:00
karanabe
08fea2415f
od: add fH and fB format specifiers 2025-07-22 19:38:21 +09:00
Nicolas Boichat
64fb7a7462 test_mkdir: Add a test for non-Unicode directory name
Similar to the first part of GNU test df/problematic-chars.
2025-07-22 17:25:59 +08:00
Nicolas Boichat
7e6e9c291e uutests: Change dir_exists to take a templated AsRef<Path>
Similar to what file_exists does, allows us to pass an OsStr to the
function.

Also change symlink_exists, for consistency.
2025-07-22 17:25:59 +08:00
Julian Andres Klode
abb5300068 install, mkdir: Handle dir/./ like dir/.
The dir/. special case was handled correctly, but dir/./ was not,
breaking gcc builds, which run:

../../../../src/libstdc++-v3/../install-sh -c -d debug/./

Bug-Ubuntu: https://bugs.launchpad.net/bugs/2117466
2025-07-22 09:44:15 +02:00
Yonatan Linik
fe4e8e234c od: Fixes float formatting in scientific notation
GNU's od adds a "+" after the "e".

Fixes [#8346](https://github.com/uutils/coreutils/issues/8346)
2025-07-18 22:40:18 +03:00
yuankunzhang
a8fe603284 stty: support sane settings 2025-07-16 22:33:33 +08:00
Andrew Liebenow
961a27acff printf: accept non-UTF-8 input in FORMAT and ARGUMENT arguments
Other implementations of `printf` permit arbitrary data to be passed
to `printf`. The only restriction is that a null byte terminates
FORMAT and ARGUMENT argument strings (since they are C strings).

The current implementation only accepts FORMAT and ARGUMENT
arguments that are valid UTF-8 (this is being enforced by clap).

This commit removes the UTF-8 validation by switching to OsStr
and OsString.

This allows users to use `printf` to transmit or reformat null-safe
but not UTF-8-safe data, such as text encoded in an 8-bit text
encoding. See the `non_utf_8_input` test for an example (ISO-8859-1
text).

[drinkcat: also squashed in this commit to ease rebase]
Author: Justin Tracey <jdt.dev@unsuspicious.click>

uucore, printf: improve non-UTF-8 format arguments

This fixes handling of format arguments, in part by eliminating duplicate
implementations. Utilities with format arguments other than printf will no
longer accept things like "'a" as numbers, etc.

Co-authored-by: Justin Tracey <jdt.dev@unsuspicious.click>
2025-07-16 00:28:34 +02:00
Dorian Péron
50704da6e8
Merge pull request #8336 from tgrez/main
cat: handle broken pipe gracefully
2025-07-15 20:56:46 +02:00
Dorian Péron
4d08b9d554
Merge pull request #8341 from cakebaker/echo_output_version
echo: show version when `--version` is the only argument
2025-07-15 19:37:48 +02:00
Tomasz Guz
11d6fe0f6f tail: fix race condition in broken pipe handling test 2025-07-14 18:25:15 +02:00
Tomasz Guz
6a6ee59c63 cat: fix race condition in broken pipe handling test 2025-07-14 18:25:15 +02:00
Tomasz Guz
4406b403b2 cat: handle broken pipe gracefully 2025-07-14 18:25:15 +02:00
Daniel Hofstetter
0ce0ea04f6 echo: rename test function 2025-07-14 12:41:12 +02:00
Daniel Hofstetter
9c08dd9851 echo: show version when using --version 2025-07-14 12:31:32 +02:00
Sylvestre Ledru
4439f7e03d du: create the string into the main thread to avoid some translations issue
should fix tests/du/inodes.sh
2025-07-14 19:23:04 +09:00
Daniel Hofstetter
afbe90feaf
Merge pull request #8310 from RGBCube/echo-help
Some checks are pending
CICD / Style/cargo-deny (push) Waiting to run
CICD / Build (push) Blocked by required conditions
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 / 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 (push) Waiting to run
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
echo: print help if not posixly correct and only argument is --help
2025-07-14 10:34:30 +02:00
RGBCube
3ea679a29e
echo: print help if not posixly corrent and only argument is --help 2025-07-12 01:37:07 +03:00
Julian Andres Klode
b585e98dac cp: Fix --no-dereference --parents with symlink source
If the source is a symbolic link pointing at a directory,
--parents was ignored, as we entered the "copy as directory"
code path.

Fixes: #8330
2025-07-11 08:09:10 +02:00
Daniel Hofstetter
685969e275
Merge pull request #8327 from tgrez/main
Some checks are pending
CICD / Build (push) Blocked by required conditions
CICD / Style/cargo-deny (push) Waiting to run
CICD / Test all features separately (push) Blocked by required conditions
CICD / Style/deps (push) Waiting to run
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 (push) Waiting to run
Android / Test builds (push) Waiting to run
Code Quality / Style/Python (push) Waiting to run
Code Quality / Style/toml (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 / Pre-commit hooks (push) Waiting to run
FreeBSD / Style and Lint (push) Waiting to run
FreeBSD / Tests (push) Waiting to run
tail: handle broken pipe gracefully
2025-07-10 16:17:37 +02:00
Tomasz Guz
f04ed45a0f tail: handle broken pipe gracefully 2025-07-10 14:54:02 +02:00
Tomasz Guz
a060344c6b uutests: improve error message for non-empty stderr 2025-07-10 14:54:02 +02:00
Will Shuttleworth
93fc669258 stty: add combination settings 2025-07-10 08:19:27 -04:00
Daniel Hofstetter
745ae4b10f
Merge pull request #8292 from RenjiSann/collating
Some checks are pending
CICD / Style/cargo-deny (push) Waiting to run
CICD / Test all features separately (push) Blocked by required conditions
CICD / Build (push) Blocked by required conditions
CICD / Style/deps (push) Waiting to run
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 (push) Waiting to run
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
i18n: further work, expr support
2025-07-09 16:24:13 +02:00
Johnothan King
6d30b9110a
tr: Fix regression causing read error with sockets (#8083)
* tr: Fix regression causing read error with sockets

The test used for determining if a file descriptor
tested with fstat points to a directory is traditionally
done by using the S_IFMT mask[^1][^2], e.g.:
    #define S_ISDIR(m)	(((m) & S_IFMT) == S_IFDIR)
In Rust, this translates to 'm & libc::S_IFMT == libc::S_IFDIR'.
is_stdin_directory() uses 'has!(mode, S_IFDIR)', which is
**not** equivalent and causes non-directory sockets to be
incorrectly recognized as directories. This causes uu-tr
to break when used with all sockets created with socketpair,
including ksh93 pipes[^3]. Below is an example Rust program
demonstrating why the current check is bogus:
  fn main() {
     use nix::sys::socket::{socketpair, SockFlag, AddressFamily, SockType};
     use nix::sys::stat::fstat;
     use libc::{S_IFDIR, S_IFMT, mode_t};
     let (_fd1, fd2) = socketpair(AddressFamily::Unix, SockType::Stream, None, SockFlag::empty()).unwrap();
     let mode = fstat(&fd2).unwrap().st_mode as mode_t;
     if mode & S_IFMT == S_IFDIR {   // Equivalent to S_ISDIR()
         println!("Not reached");    // Not a dir, so unreachable
     }
     if mode & S_IFDIR == S_IFDIR {  // Bogus check for S_IFDIR
         println!("BAD");
     }
  }

- is_stdin_directory(): Fix the regression introduced in 3e4221a4
  by replacing the bogus check with one equivalent to S_ISDIR().
- test_tr.rs: Add a regression test for this bug.

[^1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=io/sys/stat.h;h=4bea9e9a#l123
[^2]: https://git.musl-libc.org/cgit/musl/tree/include/sys/stat.h?id=047a1639#n51
[^3]: cc5e0692/src/cmd/ksh93/sh/io.c (L98-L102)

Fixes https://github.com/uutils/coreutils/issues/7658

* Add comment explaining rationale

Also fix cargo clippy lint.
(In case it isn't obvious, I'm fairly new to Rust)

* Fix more lint
2025-07-09 15:47:16 +02:00
Dorian Peron
4ab3431d08 test(expr): add locale-related tests, remove deprecated tests
- Add locale comparison test (issue #5378)
- Implement GNU expr-multibyte test
2025-07-09 15:34:07 +02:00
Yuri Astrakhan
206281e29b chore: fix uninlined_format_args lint
I used this command, plus some manual fixes:

```sh
__CARGO_FIX_YOLO=1 cargo clippy --fix --all-targets --workspace --all-features --allow-dirty
```
2025-07-09 10:50:36 +02:00
Daniel Hofstetter
f5a862c55d
Merge pull request #8315 from bvinc/head_elide_tail
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 / 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 / Test all features separately (push) Blocked by required conditions
CICD / Build/SELinux (push) Blocked by required conditions
GnuTests / Run GNU tests (push) Waiting to run
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
head: fix meaning of ---presume-input-pipe
2025-07-08 09:23:44 +02:00
Brian Vincent
20d26aa074 head: fix meaning of ---presume-input-pipe
The option ---presume-input-pipe is debug option that should
disable the seeking optimization, not force it to read stdin.
This fixes the GNU test head-elide-tail.
2025-07-07 18:37:48 -07:00
Daniel Hofstetter
b9a790b476
Merge pull request #8314 from bvinc/tail_zero
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 / 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 / Test all features separately (push) Blocked by required conditions
CICD / Build/SELinux (push) Blocked by required conditions
GnuTests / Run GNU tests (push) Waiting to run
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
tail: fix tailing /dev/zero
2025-07-07 10:30:34 +02:00
Daniel Hofstetter
2ee135e23e
Merge pull request #8309 from willshuttleworth/stty-special-settings
`stty`: special settings
2025-07-07 10:16:16 +02:00