Commit graph

12072 commits

Author SHA1 Message Date
Samuel Tardieu 32f0256d7d uucore/num_format: properly display 10ᵖ where p is the precision
`seq --format %.2g 10 10` would display `1` because the precision would
not allow room for the decimal point, and the `0` in `10` would be
trimmed as an insignificant trailing `0`.

This has been fixed by only trimming trailing `0` in the presence of a
decimal point.
2024-01-05 15:40:20 +01:00
Samuel Tardieu f5179290a6 uucore/num_format: replace saturating_sub by regular subtraction
Using `saturating_sub()` before converting to `usize` gives a wrong
feeling of security as it looks like it ensures that the value will
never go negative. However, since it is applied to `i32`, it can, and
converting it to `usize` would go horribly wrong anyway.

By following the code flow, `exponent` cannot be greater than
`precision`, or the `else` block would not have been taken.  A plain
subtraction will give the same result and will at least panic in debug
mode.
2024-01-05 15:04:12 +01:00
Samuel Tardieu 4c5326ffa3 uucore/num_format: the default precision for %g is 6 2024-01-05 15:00:12 +01:00
Daniel Hofstetter 5950777561
Merge pull request #5780 from sylvestre/terminator
cp/mv: manage with trailing slash in target
2024-01-05 14:24:08 +01:00
Dorian Péron 4372908e84 fix: cargo fmt + fix spelling mistake 2024-01-05 13:55:47 +01:00
Sylvestre Ledru e64a0b4a26 Various fixes
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-01-05 12:56:27 +01:00
Sylvestre Ledru aabf5fa577 cp: manages target with trailing '/' 2024-01-05 12:56:27 +01:00
Sylvestre Ledru cb27b9c9c3 path_ends_with_terminator: rustdoc + unittest 2024-01-05 12:56:27 +01:00
Sylvestre Ledru 108dc4a0cd Move path_ends_with_terminator from mv into uucore 2024-01-05 12:56:27 +01:00
Sylvestre Ledru 4c698d58e0 mv: support the case mkdir a && mv a e/ 2024-01-05 12:56:24 +01:00
Sylvestre Ledru e341759dfe
Merge pull request #5786 from samueltardieu/style-fixes
uucore: fix style in tests
2024-01-05 12:39:48 +01:00
Sylvestre Ledru b61e859467
Merge pull request #5787 from samueltardieu/fuzz-fix-fd-leak
fuzz: fix file descriptor leak
2024-01-05 12:38:26 +01:00
Samuel Tardieu 4343ba6695 fuzz: fix file descriptor leak 2024-01-05 11:04:16 +01:00
Samuel Tardieu e56682893f uucore: fix style in tests
- `Path::new()` returns a `&Path` and does not need to be dereferenced
- Some types can be deduced from the context and are well visible
  already (`parse_size_u128()` or `from_bytes()`)
2024-01-05 10:14:27 +01:00
Daniel Hofstetter 2ba9501013
Merge pull request #5784 from sylvestre/cp-fail
Update a GNU test error check -  tests/cp/fail-perm.sh
2024-01-05 08:31:43 +01:00
Ikko Eltociear Ashimine 9dca071b69
Fix typo in signals.rs (#5781)
* Fix typo in signals.rs

occured -> occurred

* Remove "occurred" from spell-checker:ignore

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-01-05 07:30:23 +01:00
Dorian Péron c58575edaa tests/ls: Add tests to ensure env var is used as a last resort 2024-01-05 02:10:33 +01:00
cre4ture 9b3cc5437c
head: head_backwards for non-seekable files like /proc/* or fifos (named pipes) (#5732)
* implement head_backwards for non-seekable files like /proc/* or pipes

Signed-off-by: Ulrich Hornung <hornunguli@gmx.de>
2024-01-05 00:25:59 +01:00
Sylvestre Ledru 932ea96cb6 Update a GNU test error check - tests/cp/fail-perm.sh 2024-01-05 00:03:12 +01:00
Sylvestre Ledru be816027ae
Merge pull request #5782 from samueltardieu/issue-5777
fuzz: reset the exit code global variable after every test
2024-01-04 19:47:54 +01:00
Samuel Tardieu c23dbd3166 fuzz: reset the exit code global variable after every test 2024-01-04 19:07:24 +01:00
Dorian Péron 6760d63539 ls: Fix clippy warning 2024-01-04 16:51:30 +01:00
Sylvestre Ledru d07a2f0d86
Add new fuzzers: cut, sort, split and wc (#5760)
* fuzz: use thread to bypass the limitation of output

Closes: #5724

many thanks to @samueltardieu

* fuzz: enable seq as the stalled issue is fixed

* fuzz: add 4 more fuzzers

* fuzz: enable the 4 new fuzzers in the CI

* remove old import

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

* remove comment

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

* remove comment

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

* add more flags

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

* add space

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

* add a comment about sort local

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

* wrong copy/paste

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

* fuzz: import "std::env"

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-01-04 13:40:47 +01:00
Daniel Hofstetter b74953ab0e
Merge pull request #5779 from sylvestre/gnu-dl
gnu compare: try to use a local copy if the download failed
2024-01-04 08:19:58 +01:00
Sylvestre Ledru 217aa3bd9d gnu compare: try to use a local copy if the download failed 2024-01-03 20:42:25 +01:00
Dorian Péron e30f191579 ls: Handle the use of QUOTING_STYLE variable 2024-01-03 18:37:51 +01:00
Sylvestre Ledru 78405e6a30
Merge pull request #5775 from cakebaker/du_ignore_duplicate_files_files0_from
du: ignore duplicate names with `--files0-from`
2024-01-03 16:49:40 +01:00
Daniel Hofstetter f3833bb652
Merge pull request #5758 from sylvestre/fuzz-thread
fuzz: use thread to bypass the limitation of output
2024-01-03 14:47:52 +01:00
Daniel Hofstetter 244693f50e
Merge pull request #5776 from tdelmas/patch-1
META bug: moved to project mgmt
2024-01-03 11:38:53 +01:00
Tom c9f796b694
META bug: moved to project mgmt
https://github.com/uutils/coreutils/issues/3336#issuecomment-1206292911
2024-01-03 11:24:01 +01:00
Daniel Hofstetter 442da9ac54
Merge pull request #5774 from lcheylus/bsd-scripts
Fix util shell scripts to be compatible with BSD
2024-01-03 10:45:19 +01:00
Daniel Hofstetter e4fbc31714 du: ignore duplicate names with --files0-from 2024-01-03 09:39:16 +01:00
Daniel Hofstetter 38282b4df2
Merge pull request #5773 from sylvestre/require_root
remaining-gnu-error.py: shows when a test requires root
2024-01-03 08:02:54 +01:00
Laurent Cheylus be58798078
DEVELOPMENT.md: on FreeBSD, install GNU coreutils package to build/run tests
Signed-off-by: Laurent Cheylus <foxy@free.fr>
2024-01-02 22:05:03 +01:00
Laurent Cheylus 0bc70e3ba1
CI: install GNU coreutils package for FreeBSD workflow
- util/show-utils.sh script is used by FreeBSD workflow => use realpath
    command from GNU coreutils instead of FreeBSD realpath.
  - install GNU coreutils (FreeBSD package coreutils) in style job

Signed-off-by: Laurent Cheylus <foxy@free.fr>
2024-01-02 22:05:03 +01:00
Laurent Cheylus 13665da85e
run-gnu-test.sh: modify script to be compatible with BSD OS
- Use /usr/bin/env bash instead of /bin/sh to use OSTYPE
  - Define variables for GNU version of make, nproc, readlink and use them on BSD.

Signed-off-by: Laurent Cheylus <foxy@free.fr>
2024-01-02 22:05:02 +01:00
Laurent Cheylus aef204461c
util: modify scripts for code coverage to be compatible with BSD OS
- Use /usr/bin/env bash instead of /bin/sh to use OSTYPE
  - Use readlink from GNU coreutils on BSD OS in util/build-code_coverage.sh and
    util/show-code_coverage.sh scripts

Signed-off-by: Laurent Cheylus <foxy@free.fr>
2024-01-02 22:05:02 +01:00
Laurent Cheylus d450d5a463
show-utils.sh: modify script to be compatible with BSD OS
- Use /usr/bin/env bash instead of /bin/sh to define OSTYPE
  - Use GNU realpath on BSD OS (FreeBSD and OpenBSD)

Signed-off-by: Laurent Cheylus <foxy@free.fr>
2024-01-02 22:05:02 +01:00
Laurent Cheylus 7aca1f932a
build-gnu.sh: modify script to be compatible with BSD OS
- Define variables for GNU version of make, nproc, readlink and sed and use them on BSD.
  - In specific cases (option -z not available on BSD and with command /c), use GNU sed instead of
    BSD sed.
  - For xargs, --no-run-if-empty option is a GNU extension. Replace it by -r to be compatible with
    FreeBSD and OpenBSD xargs command.

Signed-off-by: Laurent Cheylus <foxy@free.fr>
2024-01-02 22:05:02 +01:00
Laurent Cheylus 6d3345cfec
util: use env to call bash in shell scripts
- For shell scripts using bash, use #!/usr/bin/env bash instead of #!/bin/bash.
    On some OS, bash is not the default shell and is not installed as /bin/bash

Signed-off-by: Laurent Cheylus <foxy@free.fr>
2024-01-02 22:05:02 +01:00
Sylvestre Ledru 4a28b1674a remaining-gnu-error.py: shows when a test requires root 2024-01-02 20:33:21 +01:00
Sylvestre Ledru 8df064e1fa
Merge pull request #5772 from cakebaker/du_files0_from_zero_length_file_name
du: show error for nul names with `--files0-from`
2024-01-02 19:53:15 +01:00
Daniel Hofstetter 239e5426e6 du: show error for nul names with --files0-from 2024-01-02 16:06:41 +01:00
Daniel Hofstetter 9f257adf59
Merge pull request #5765 from sylvestre/handle-full
handle the error when stdout is full
2024-01-02 08:31:19 +01:00
Daniel Hofstetter 2a81c91f52
Merge pull request #5771 from sylvestre/tail-error
tail: transform FAIL into ERROR for tests/tail/inotify-rotate-resources.sh
2024-01-02 07:20:25 +01:00
Daniel Hofstetter 34c0861d96
Merge pull request #5770 from sylvestre/cp-leap-error
Workaround https://github.com/uutils/coreutils/issues/5766
2024-01-02 07:14:41 +01:00
Sylvestre Ledru 203600bb9c tail: transform FAIL into ERROR for tests/tail/inotify-rotate-resources.sh 2024-01-02 00:42:52 +01:00
Sylvestre Ledru d640e690f4 Workaround https://github.com/uutils/coreutils/issues/5766
to transform an ERROR into FAIL
2024-01-02 00:13:20 +01:00
Sylvestre Ledru 2c73e978ba
Merge pull request #5769 from samueltardieu/is-ok-and
test: use clearer expression for CI testing
2024-01-01 22:45:37 +01:00
Samuel Tardieu 05d85618e3 test: use clearer expression for CI testing
`bool::is_ok_and()` is available in Rust 1.70.0 and above, which is compatible
with the current MSRV.
2024-01-01 21:04:13 +01:00