Commit graph

6751 commits

Author SHA1 Message Date
Samuel Tardieu
7d32e49fb9 printf: %c prints the first byte of its argument 2024-01-10 18:19:56 +01:00
Terts Diepraam
0071442cba
Merge pull request #5783 from samueltardieu/printf-compatibility
printf compatibility
2024-01-10 16:33:37 +01:00
Samuel Tardieu
a85a792c88 format: use the new number parser and fix the error messages
The error messages are more compliant with GNU coreutils.
Also, floating hexadecimal numbers are now supported in
`printf`.
2024-01-10 14:34:43 +01:00
Samuel Tardieu
00cd6fa347 format: new dedicated number parser
The parser can parse integral and floating point numbers as expected by
the coreutils `printf` command.
2024-01-10 14:34:43 +01:00
Terts Diepraam
9858fef20e printf: use 0 instead of 0o as octal prefix 2024-01-09 10:34:08 +01:00
Samuel Tardieu
5dfeca9ff2 format: %c prints the first character of a string 2024-01-09 00:13:54 +01:00
Atomei Alexandru Constantin
288ad97878 Made cksum to return an error if the algorithm blake2b is used on a directory 2024-01-07 23:39:33 +02:00
Sylvestre Ledru
b309d64e78
Merge branch 'main' into issue-5766 2024-01-06 22:55:54 +01:00
Kostiantyn Hryshchuk
c867d6bfb1
shred: implemented "--remove" arg (#5790) 2024-01-06 22:50:21 +01:00
Sylvestre Ledru
247f2e55bd
seq: adjust some error messages. GNU's are better (#5798)
* seq: adjust some error messages. GNU's are better
tested by tests/seq/seq.pl

* uucore: remove todo

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-01-06 16:54:29 +01:00
Fabrice Fontaine
9f4330f94c uucore: add support for sparc64
Add support for sparc64 in uucore to avoid the following build failure
with nushell:

error[E0308]: mismatched types
   --> /home/autobuild/autobuild/instance-7/output-1/build/nushell-0.85.0/VENDOR/uucore/src/lib/features/fs.rs:121:16
    |
111 |     pub fn number_of_links(&self) -> u64 {
    |                                      --- expected `u64` because of return type
...
121 |         return self.0.st_nlink;
    |                ^^^^^^^^^^^^^^^ expected `u64`, found `u32`
    |
help: you can convert a `u32` to a `u64`
    |
121 |         return self.0.st_nlink.into();
    |                               +++++++

For more information about this error, try `rustc --explain E0308`.
error: could not compile `uucore` (lib) due to previous error

Fixes:
 - http://autobuild.buildroot.org/results/f9f0287a8e39c65895014ca513ed25071f020add

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2024-01-06 10:26:54 +01:00
Michel Lind
5de030f119
uuhelp_parser: add links to homepage and repo
When viewing the crate right now, apart from via looking at the dependencies
it's hard to find the associated project and repository.

Add the missing info.

Signed-off-by: Michel Lind <salimma@fedoraproject.org>
2024-01-05 22:21:28 -06:00
Daniel Hofstetter
e13f0d80ee
Merge pull request #5778 from RenjiSann/main
ls: Support QUOTING_STYLE environment variable
2024-01-05 15:55:23 +01:00
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
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
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
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
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
Dorian Péron
6760d63539 ls: Fix clippy warning 2024-01-04 16:51:30 +01:00
Dorian Péron
e30f191579 ls: Handle the use of QUOTING_STYLE variable 2024-01-03 18:37:51 +01:00
Daniel Hofstetter
e4fbc31714 du: ignore duplicate names with --files0-from 2024-01-03 09:39:16 +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
Sylvestre Ledru
f53f9b6496 handle the error when stdout is full
Avoid panic when using
seq 1 >/dev/full

Should move tests/csplit/csplit-io-err.sh from ERROR to SKIP
2024-01-01 17:00:10 +01:00
Daniel Hofstetter
01e12120c1 mv: simplify condition 2024-01-01 16:48:06 +01:00
Daniel Hofstetter
5673f32c63 cp: show error if source & dest are same file 2023-12-31 16:01:34 +01:00
Sylvestre Ledru
b07ea957d3 rm: improve the code a tiny bit 2023-12-31 12:03:42 +01:00
Sylvestre Ledru
5fc01f718a
Merge pull request #5747 from Ato2207/fix_docs
Fix docs issues.
2023-12-30 19:28:54 +01:00
Vardhan Patil
d990021572 cksum: remove redundant guard 2023-12-30 20:39:09 +05:30
Vardhan Patil
e7cb4e9ff0 cksum: properly handle cases where --lenghth is 0 or >512 2023-12-30 20:28:03 +05:30
Atomei Alexandru
5ade45f8e9
Merge branch 'main' into fix_docs 2023-12-30 15:43:54 +02:00
Vardhan Patil
aec0cfa6e3 cksum: remove commented code 2023-12-30 16:05:20 +05:30
Vardhan Patil
7caa0bcdea cksum: fix formatting in cksum.rs 2023-12-30 16:02:10 +05:30
Vardhan Patil
037073d852 cksum: make the output formatting match GNU 2023-12-30 15:59:29 +05:30
Sylvestre Ledru
138b11efbd
remove extra spaces 2023-12-30 09:53:32 +01:00
Vardhan Patil
231987b109 cksum: create initial implementation of the --length option 2023-12-30 12:48:19 +05:30
Matei Mantu
21d09dd404
ls: unquoted names should be indented with a space if there is a quoted name (#5740)
* ls: change indentation when file names include quotes to match GNU's

* display_grid: Changed order of parameters because it made more sense

* ls -l: Add padding for unquoted filenames

* Fix checking for quoted filenames

* Simplify if
2023-12-29 15:19:26 +01:00
Sylvestre Ledru
448e4c2224
Merge pull request #5745 from cakebaker/cp_adapt_warning
cp: adapt warning if source is used more than once
2023-12-29 15:09:24 +01:00
Alexandru-Constantin Atomei
d15981650a Fixed one typo 2023-12-29 15:08:50 +01:00
Alexandru-Constantin Atomei
1e5244765d Made one more modification to test usage string. 2023-12-29 15:08:50 +01:00
Alexandru-Constantin Atomei
e61318413e Added documentation for the vdir command. 2023-12-29 15:08:50 +01:00
Alexandru-Constantin Atomei
ce28ae5c02 Fixed more and test docs 2023-12-29 15:08:50 +01:00
Sylvestre Ledru
f8f82774c3
Merge pull request #5696 from dvalere/my-conts
src: Fixing typos in signatures for the argument parser
2023-12-29 15:08:39 +01:00