Commit graph

16123 commits

Author SHA1 Message Date
Nicolas Boichat
b13bf37f7b util/build-gnu.sh: Change string matching for tests/ls/time-style-diag.sh
We now are closer to what GNU prints, and handle the [posix-] cases
that they do.
2025-07-30 19:45:29 +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
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
b99615c1e3 du/ls: Move common time formats to constants in uucore/time
Along the way:
 - Fix the full-iso format, that was supposed to use %N, not %f
   (%f padded with chrono, but not with jiff, and %N is more correct
   and what GNU says in their manual)
 - The Hashmap thing in parse_time_style was too smart, to a point
   that it became too unflexible (it would have been even worse
   when we added locale support).

I was hoping the share more of the code, but that seems difficult.
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
Sylvestre Ledru
e48c4a7b96
Merge pull request #8398 from drinkcat/stat-bigtime
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 (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
`stat`: Convert to use `uucore` functions
2025-07-30 10:18:23 +02:00
Sylvestre Ledru
a055e856dd
fix rustfmt 2025-07-30 09:51:14 +02:00
Sylvestre Ledru
e68f73489c
Merge branch 'main' into stat-bigtime 2025-07-30 09:29:19 +02:00
Daniel Hofstetter
4a68e3d05c
Merge pull request #8414 from uutils/renovate/clap-4.x-lockfile
chore(deps): update rust crate clap to v4.5.42
2025-07-30 07:46:53 +02:00
renovate[bot]
4b37f6d48d
chore(deps): update rust crate clap to v4.5.42 2025-07-30 05:04:00 +00:00
Dorian Péron
2307a353ea
Merge pull request #8406 from amirhosseinghanipour/refactor-mkdir-mode-parsing
Some checks are pending
CICD / Style/cargo-deny (push) Waiting to run
CICD / Build/nightly (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 / 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/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
refactor(mkdir): Simplify mode argument parsing
2025-07-29 22:02:34 +02:00
Dorian Péron
614531d13c
Merge branch 'main' into refactor-mkdir-mode-parsing 2025-07-29 22:01:53 +02:00
Sylvestre Ledru
35610ba146
Merge pull request #8413 from cakebaker/mv_improve_is_empty_dir
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 / 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
FreeBSD / Style and Lint (push) Waiting to run
FreeBSD / Tests (push) Waiting to run
mv: use `next()` instead of `peekable().peek()` in `is_empty_dir()`
2025-07-29 17:25:47 +02:00
Sylvestre Ledru
3a214f2842
Merge branch 'main' into refactor-mkdir-mode-parsing 2025-07-29 16:54:15 +02:00
Daniel Hofstetter
000be5b73a mv: use next() instead of peekable().peek()
in is_empty_dir()
2025-07-29 16:52:06 +02:00
Amirhossein Ghanipour
8c9e739694 refactor(mkdir): Simplify mode argument parsing 2025-07-29 15:11:35 +03:30
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
Sylvestre Ledru
386acd00d6
Merge pull request #8412 from julian-klode/fix-install-no-target-existing-target
install: Fix --no-target-directory with existing file
2025-07-29 12:46:40 +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
33a3f734a7
Merge pull request #8405 from sylvestre/tz-deprecated
date: update deprecated TZ
2025-07-29 11:35:05 +02:00
Dorian Péron
0fac1cd00b
Merge pull request #8411 from cakebaker/who_rename_var
who: rename var, cleanup spell-checker:ignore
2025-07-29 11:15:43 +02:00
Daniel Hofstetter
361f1b9ce5 who: rename var, cleanup spell-checker:ignore 2025-07-29 10:19:09 +02:00
Daniel Hofstetter
78d3845844
Merge pull request #8410 from uutils/renovate/clap_mangen-0.x-lockfile
Some checks are pending
CICD / Style/deps (push) Waiting to run
CICD / Style/cargo-deny (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/SELinux (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
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
chore(deps): update rust crate clap_mangen to v0.2.29
2025-07-29 09:49:55 +02:00
Daniel Hofstetter
294e29deb2
Merge pull request #8392 from sylvestre/l10n-macros
Create macros for l10n translations
2025-07-29 09:46:20 +02:00
renovate[bot]
435ac9438f
chore(deps): update rust crate clap_mangen to v0.2.29 2025-07-29 07:26:46 +00:00
Sylvestre Ledru
9c01ef53d2
Merge pull request #8409 from amirhosseinghanipour/style/simplify-physical-path
style(pwd): simplify physical_path implementation
2025-07-29 09:24:30 +02:00
Amirhossein Ghanipour
aff71abdc4 style(pwd): simplify physical_path implementation 2025-07-29 07:14:28 +03:30
Sylvestre Ledru
a73ecd95e6 uucore: adjust it too to use the translate macro 2025-07-28 22:04:40 +02:00
Sylvestre Ledru
50fc84136f l10n: Use FluentArgs instead of HashMap directly 2025-07-28 22:04:40 +02:00
Sylvestre Ledru
d045f50622 l10n: adjust the documentation 2025-07-28 22:04:40 +02:00
Sylvestre Ledru
862a7a705c use the new translate! macro for translation
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2025-07-28 22:04:40 +02:00
Sylvestre Ledru
bd005d12b9 uucore/locale: create a macro to simplify the translation calls 2025-07-28 21:32:54 +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
8428291461 fsext: Fix metadata_get_time for change time (ctime) before 1970
Useful for archaeologists and time travellers, do not crash if
ctime is before 1970.

Creating a file with such a change time is a bit challenging
(touch can't change that), so we can't easily add end-to-end
tests.

Steps to create a filesystem with a file `x` with birth/change
time in 1960.
```
dd if=/dev/zero bs=100M count=0 seek=1 of=ext4
mkfs.ext4 ext4
sudo mount ext4 mnt
touch mnt/x
umount mnt
echo "set_inode_field x ctime 196001010101" | debugfs -w ext4
echo "set_inode_field x ctime_extra 1234" | debugfs -w ext4
echo "set_inode_field x crtime 196001010101" | debugfs -w ext4
echo "set_inode_field x crtime_extra 0x123400" | debugfs -w ext4
sudo mount ext4 mnt
```

$ cargo run -p uu_stat mnt/x
  File: mnt/x
  size: 0         	Blocks: 0          IO Block: 1024   regular empty file
Device: 700h/1792d	Inode: 13          Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2025-07-26 19:52:00.849821694 +0800
Modify: 2025-07-26 19:52:00.849821694 +0800
Change: 1960-01-02 09:01:00.000298240 +0800
 Birth: 1960-01-02 09:01:00.000298240 +0800
2025-07-28 21:16:11 +08:00
Nicolas Boichat
6c73ef6226 uucore: time: Add options for format_system_time
Depending on the caller, we want the number of seconds, that
and an error printed out, or seconds+nanoseconds.
2025-07-28 21:16:11 +08:00
Nicolas Boichat
6eb75f2d93 stat: Stop relying on fsext::Birth
We can rely on other fsext/time functions, and stay a bit more
consistent.
2025-07-28 21:16:11 +08:00
Nicolas Boichat
9c13e3f518 stat: Use uucore::time:format_system_time function 2025-07-28 21:16:11 +08:00
Sylvestre Ledru
fb4d611445
Merge pull request #8404 from drinkcat/stat-fluent
Some checks are pending
CICD / Build (push) Blocked by required conditions
CICD / Test all features separately (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 / 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
stat/locales: Fix fluent_linter errors
2025-07-28 14:07:46 +02:00
Nicolas Boichat
2c106609cc stat/locales: Fix fluent_linter errors
Arguably this should be part of the CI, but I'm not sure how
to run it outside of precommit.
2025-07-28 17:22:53 +08:00
Sylvestre Ledru
809e75cf39
Merge pull request #8401 from drinkcat/selinux-fifo-symlinks
Some checks are pending
CICD / Style/cargo-deny (push) Waiting to run
CICD / Build/nightly (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 / 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/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
selinux: Fix get_context on fifos (and symlinks)
2025-07-28 09:40:05 +02:00
Nicolas Boichat
49b2466a9c uucore: selinux: Add tests for symlinks and fifo
Check that we can follow (or not) symlinks to get their SElinux context.

Also, check that we can get context from a fifo (we used to hang).
2025-07-28 15:08:21 +08:00
Nicolas Boichat
8752c0c098 uucore: selinux: Use of_path instead of open+of_file
Opening a pipe may just hang forever, and is not needed to get
selinux context.

Also, pass around follow_symbolic_links parameter from stat to of_path.
2025-07-28 15:08:05 +08:00
Daniel Hofstetter
8236bcff28
Merge pull request #8400 from uutils/renovate/ctor-0.x-lockfile
chore(deps): update rust crate ctor to v0.4.3
2025-07-28 07:09:38 +02:00