Commit graph

7127 commits

Author SHA1 Message Date
Ulrich Hornung
30d61d8a97
extract more functions for run_env() 2024-03-22 23:06:35 +01:00
Ulrich Hornung
59df0b8fb8
replace comment with extracted function 2024-03-22 22:36:57 +01:00
Ulrich Hornung
4c1e68c9f4
replace comment with extracted function 2024-03-22 22:34:05 +01:00
Ulrich Hornung
526cc8846c
extract functions blocks to reduce cognitive complexity 2024-03-22 22:17:48 +01:00
Daniel Hofstetter
5e6fa49ef5 more: fix incorrect tests 2024-03-22 15:13:53 +01:00
Krysztal112233
35c39a65e5
Merge branch 'uutils:main' into main 2024-03-22 16:48:47 +08:00
Krysztal112233
48e376e1e0
lint: allow clippy::suspicious_open_options in sort.rs 2024-03-22 00:42:33 +08:00
Krysztal112233
2b5e7caf8b
lint: fix clippy::manual_str_repeat in parse_glob.rs 2024-03-22 00:02:04 +08:00
Krysztal112233
eb3fac3567
lint: fix clippy::needless_borrows_for_generic_args in perms.rs 2024-03-21 23:54:37 +08:00
Krysztal112233
b66d6dffcf
lint: fix clippy::needless_borrows_for_generic_args in perms.rs 2024-03-21 23:53:32 +08:00
Krysztal112233
72b7266f71
lint: allow clippy::needless_borrow in perms.rs 2024-03-21 23:50:23 +08:00
Krysztal112233
0bb179311d
lint: fix clippy::bool_assert_comparison in perms.rs 2024-03-21 23:47:57 +08:00
Krysztal112233
63d92cdbda
lint: fix clippy::useless_vec in unit_tests.rs 2024-03-21 23:46:24 +08:00
Krysztal112233
21d6eab847
lint: fix lint clippy::suspicious_open_options 2024-03-21 23:36:48 +08:00
hanbings
c35c96f127
Merge branch 'main' into main 2024-03-21 22:57:20 +08:00
hanbings
30452ced73
Add 0xDE flag to to support zfs file system. 2024-03-21 22:20:31 +08:00
Daniel Hofstetter
77a67559eb
Merge pull request #5966 from Ideflop/more-implement-argument-pattern
More implement argument pattern
2024-03-21 10:51:31 +01:00
Sylvestre Ledru
597a29be46
Merge pull request #6095 from cakebaker/cksum_enable_encoding_feature
cksum: enable encoding feature
2024-03-20 11:10:59 +01:00
Daniel Hofstetter
3ad226cf54 fmt: show error if goal > default width 2024-03-20 10:26:11 +01:00
Daniel Hofstetter
45bdca9f16 fmt: replace two magic numbers with consts 2024-03-20 10:23:33 +01:00
sreehari prasad
660014e532
dd: misc gnu test (#6084)
* dd: check file is a dir for iflag directory

* Improve english

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

* dd: stderr output checking for "iflag directory" testcase

* dd: replace #[cfg(unix)] with #[test]

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-03-20 06:55:54 +01:00
Sylvestre Ledru
08172c28c0
Merge pull request #5801 from cre4ture/feature/env_string_args_try_with_shell_words
env: support string args by "-S", "-vS" or "--split-strings"
2024-03-19 19:32:04 +01:00
Daniel Hofstetter
7c8dfca4a7
Merge pull request #6094 from sargas/fmt-small-widths
fmt: Make sure goal is always positive
2024-03-19 16:55:10 +01:00
Joseph Jon Booker
f456b9531f fmt: Make sure goal is always positive
A debug assertion was added to enforce "width >= goal" to catch
that case before a panic in linebreak.rs. A few warnings in linebreak.rs
were addressed as well, and some isize's that should always be positive
(if there's no width/goal bugs) were changed to usizes to catch bugs
earlier.

test_fmt_width is updated to test for the same result as GNU fmt
2024-03-19 08:52:04 -05:00
Daniel Hofstetter
2b4cfcc8b8 cksum: enable encoding feature 2024-03-19 09:29:41 +01:00
Ulrich Hornung
c62ba559d0 env: support string args by "-S", "-vS" or "--split-strings" 2024-03-19 00:45:05 +01:00
Ben Wiederhake
133cdde885 cksum: implement and test --base64 output method 2024-03-18 20:59:59 +01:00
Ben Wiederhake
7b219aee63 cksum: implement trivial --tag flag 2024-03-18 20:59:59 +01:00
Ben Wiederhake
edb1eb0a76 cksum: allow repeated flags and arguments 2024-03-18 20:59:59 +01:00
Ulrich Hornung
32b5591736
df: switch from u64 to u128 to handle fs with large inodes nr (#6071) 2024-03-18 17:03:23 +01:00
Daniel Hofstetter
05731d13af
tr: remove fixed todo 2024-03-18 13:56:49 +01:00
Krysztal112233
4712015e61 tr: lazily generate the character mapping as necessary 2024-03-18 18:33:07 +08:00
Daniel Hofstetter
e569b0bbe1 csplit: remove "crate_name" attribute 2024-03-18 09:43:30 +01:00
Daniel Hofstetter
2f4969c0e9
Merge pull request #6090 from sylvestre/csplit2
csplit: adjust the error message to match GNU's
2024-03-18 09:33:54 +01:00
Sylvestre Ledru
696615099c
Merge pull request #6088 from cre4ture/fix/gnu_test_dd_not_rewound_sh
`dd` fix gnu test `not-rewound.sh`
2024-03-17 23:03:22 +01:00
Ulrich Hornung
40577177b2
re-use existing fd for stdout even if its a seek-able file
this is important as the fd holds the file offset we need to use
2024-03-17 20:46:49 +01:00
Sylvestre Ledru
b49fbd9a21 csplit: run the file check before the arguments verifications 2024-03-17 19:09:34 +01:00
Sylvestre Ledru
8551c55ab3 csplit: adjust the error message to match GNU's
Should fix tests/csplit/csplit
2024-03-16 22:21:44 +01:00
Daniel Hofstetter
e450ce8af2
Merge pull request #6072 from zhitkoff/cut-delim
cut: refactor delimiters OsString handling
2024-03-15 16:33:42 +01:00
Daniel Hofstetter
6d8b21da80 Fix two "item x is imported redundantly" warnings 2024-03-15 14:53:00 +01:00
Sylvestre Ledru
62a3fb8d3f
Merge pull request #5909 from cakebaker/split_fix_error_message_if_file_doesnt_exist
split: fix error message shown if file doesn't exist
2024-03-13 17:41:56 +01:00
zhitkoff
4f9497f266 cut: refactor delimiters osstring 2024-03-12 18:02:43 -04:00
Ulrich Hornung
38b15c9736
wait for child to stop after sending signal 2024-03-12 19:04:46 +01:00
Ulrich Hornung
abfd000367
avoid sending twice same signal to child process 2024-03-12 19:04:15 +01:00
Sylvestre Ledru
1725479c06
hashsum: also escape/unescape files with checks (#5868)
* hashsum: make tag conflicts with --text and --check

* hashsum: change the case in one of the gnu test

* build-gnu.sh: use symlink instead of copy

Plus: it won't cp new md5

* hashsum: also escape/unescape files with checks

Should fix tests/cksum/md5sum-bsd.sh

* improve the variable name

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

* Improve test

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

* Improve test

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

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-03-12 14:56:27 +01:00
Daniel Hofstetter
c619dbc99c split: fix error msg shown if file doesn't exist 2024-03-12 14:28:25 +01:00
Daniel Hofstetter
14ac1e160f cat: adapt to type change of unistd::write()
nix 0.28 changed "write(fd: RawFd, buf: &[u8]) -> Result<usize>" to "write<Fd: AsFd>(fd: Fd, buf: &[u8]) -> Result<usize>"
2024-03-12 08:31:15 +01:00
Daniel Hofstetter
6fd37da3e2 stty: remove ofill output flag
flag was removed from nix::sys::termios::OutputFlags in nix 0.28
2024-03-12 08:31:15 +01:00
Daniel Hofstetter
1413054c53 tty: unistd::ttyname takes AsFd instead of RawFd
change introduced by nix 0.28
2024-03-12 08:31:15 +01:00
Daniel Hofstetter
15cb0242ea uucore/pipes: adapt to new return type of nix fn
nix 0.28 changed the return type of unistd::pipe() from Result<(RawFd, RawFd), Error> to Result<(OwnedFd, OwnedFd), Error>
2024-03-12 08:31:15 +01:00
Sylvestre Ledru
ffb70592ec
Merge pull request #5851 from cre4ture/fix/install_invalid_link_at_destination
Fix install: invalid link at destination
2024-03-12 08:02:18 +01:00
Ulrich Hornung
7cd754eb1f
Fix install: invalid link at destination
also remove some FixMEs for FreeBsd
2024-03-11 23:31:26 +01:00
Sylvestre Ledru
93b1abff39
Merge pull request #6036 from cj-zoltan-kiss/zoltankiss/globfix
parser: if closing square bracket not found, stop looking for it again
2024-03-11 19:51:18 +01:00
Zoltan Kiss
be24742282 parser: if closing square bracket not found, stop looking for it again
This solves #5584, where the fuzzing would take hours without this.
2024-03-11 17:24:01 +01:00
Sylvestre Ledru
df585edff9 cp: Split the copy_file function a bit 2024-03-11 14:55:22 +01:00
Sylvestre Ledru
89b326fe1e
cp: improve the support of --attributes-only (#6051)
* cp: improve the support of --attributes-only

* remove useless comments

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

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-03-11 08:35:27 +01:00
Sylvestre Ledru
80702d5391
Merge pull request #6014 from BenWiederhake/dev-shuf-range-off-by-one
shuf: Fix off-by-one errors in range handling
2024-03-10 22:44:12 +01:00
Sylvestre Ledru
fe0c814bd5
Merge pull request #6012 from BenWiederhake/dev-tr-stream
tr: Stream output instead of buffering
2024-03-10 22:38:13 +01:00
Sylvestre Ledru
2e8f0e501c
Merge pull request #6039 from BenWiederhake/dev-chcon-repeat-args
chcon: Handle repeated flags and overrides between --no-XXX and --XXX
2024-03-10 22:36:57 +01:00
Yury Zhytkou
156d3f7ee7
cut: allow non utf8 characters for delimiters (#6037) 2024-03-10 22:36:17 +01:00
Ideflop
986c70c098 more: add test for search_pattern_in_file function 2024-03-10 22:14:26 +01:00
Ideflop
fbd3fa3f21 more: implementing pattern option 2024-03-10 22:14:26 +01:00
Terts Diepraam
a578fe9e55
Merge pull request #6050 from matrixhead/main
dd : treat arg as bytes if it contains a 'B'
2024-03-10 12:52:29 +01:00
Yash Thakur
d11d595fda
touch: Respect -h when getting metadata (#5951)
* Add tests that stat symlinks

* Check follow first in stat

* Don't run tests on FreeBSD

It would be possible to get them to run on FreeBSD by avoiding
get_symlink_times, but the behavior we're testing is not
platform-specific, so it's fine to not test it on FreeBSD.

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2024-03-10 08:05:59 +01:00
Sylvestre Ledru
8c7940260b
Merge pull request #6047 from cakebaker/bump_chrono
Bump chrono to 0.4.35 & replace usage of deprecated functions
2024-03-10 07:51:50 +01:00
Ben Wiederhake
8be5f7a89d chcon: allow repeated flags and arguments 2024-03-09 22:52:55 +01:00
Ben Wiederhake
dbfd4d80ee chcon: allow overriding between --dereference and --no-dereference 2024-03-09 22:52:55 +01:00
Ben Wiederhake
b233569b9c shuf: fix error message text on negative-sized ranges
Found by @cakebaker:
https://github.com/uutils/coreutils/pull/6011#discussion_r1501838317
2024-03-09 22:51:13 +01:00
Ben Wiederhake
4ee3f68e6a shuf: fix and test off-by-one errors around ranges 2024-03-09 22:51:13 +01:00
Ben Wiederhake
9cbe6055fa tr: stream output instead of buffering
This should lower memory consumption, and fixes OOM in some scenarios.
2024-03-09 22:51:04 +01:00
Sylvestre Ledru
6c29ed037b
Merge pull request #6042 from BenWiederhake/dev-chown-preserve-root
chown+chgrp+chmod: Fix handling of preserve root flag and error messages
2024-03-09 22:44:59 +01:00
mhead
1819cdee3b dd: treat arg as bytes if it contains 'B' 2024-03-10 01:38:50 +05:30
Ulrich Hornung
dab02d005d
split: close as much fds as needed for opening new one 2024-03-07 23:49:27 +01:00
Ben Wiederhake
d25d994125 uucore: drop unused function resolve_relative_path
This function is by necessity ill-defined: Depending on the context,
'..' is either the logical parent directory, sometimes the physical
parent directory. This function can only work for the latter case,
in which case `Path::canonicalize` is often a better approach.
2024-03-07 14:58:02 +01:00
Ben Wiederhake
5c2c38c31e chgrp+chown: also trigger preserve-root during dirwalking, fix error message
This is explicitly tested in the GNU tests.
2024-03-07 14:58:02 +01:00
Ben Wiederhake
bf5d7f786b chmod: slightly adjust error message when preserve-root is triggered
One of the GNU tests checks for the exact error message.
2024-03-07 14:49:41 +01:00
Daniel Hofstetter
aad8f7d8b5 touch: replace use of deprecated chrono functions 2024-03-06 18:16:49 +01:00
Daniel Hofstetter
c45c00eed4 ls: use chrono::TimeDelta::try_seconds instead of
deprecated chrono::TimeDelta::seconds
2024-03-06 17:51:19 +01:00
Ulrich Hornung
294c9de3ae extend error message for case when writer instanciation fails second time 2024-03-05 20:43:25 +01:00
Ben Wiederhake
cd70d7dec1 cat: ignore -u flag, just like GNU does 2024-03-01 23:56:30 +01:00
Ben Wiederhake
472b56f0ff cat: fix -b and -n anti-symmetry 2024-03-01 23:56:30 +01:00
Ben Wiederhake
100a48fda9 cat: permit repeating command-line flags 2024-03-01 23:56:30 +01:00
Dorian Péron
7094ff17cf printf: Raise error on '%0c' and '%0s' formats 2024-03-01 00:15:58 +01:00
Daniel Hofstetter
5d359783a0
uucore/format: add padlen to spell-checker:ignore 2024-02-29 15:27:11 +01:00
Dorian Péron
42cde767d2 printf: Change get_char and write_padded to handle bytes instead of chars 2024-02-29 00:59:08 +01:00
Daniel Hofstetter
aa0d15d1ac
Merge pull request #6011 from BenWiederhake/dev-shuf-repeat-zero-items
shuf: Refuse repeating zero lines
2024-02-27 15:28:06 +01:00
Daniel Hofstetter
ae7d03cb15
Merge pull request #6007 from BenWiederhake/dev-basexx-multi-arg
base32/base64/basenc: implement and test proper flag parsing
2024-02-27 15:03:47 +01:00
Daniel Hofstetter
8b2a2921c5
Merge pull request #6018 from BenWiederhake/dev-basename-multi-arg
basename: Fix handling of repeated flags/arguments
2024-02-27 10:03:14 +01:00
Matei Mantu
095eced4be
chmod: Fix chmod -c --reference reporting when no change is made (#6016)
* Make fperm hold 6 digit octal permission. Set it to 4 digits when displaying

* Add test

* Make every permission 4 octal digits

* Change test name to be more suggestive

* chmod: merge two args in test

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-02-26 11:01:50 +01:00
Ben Wiederhake
f905d9ce41 basename: implement and test repeated flags and arguments
Note in particular that `args_override_self` would *NOT* work here,
since it would in all cases cause `options::NAME` to override itself,
or interfere with `trailing_var_arg`.
2024-02-25 19:45:32 +01:00
Ben Wiederhake
9441806a23 basename: test flag implications, document -z correctly 2024-02-25 19:14:17 +01:00
Ben Wiederhake
6834b593ee shuf: refuse repeating zero lines
This was a GNU behavior bug:

```console
$ LC_ALL=C shuf -er
shuf: no lines to repeat
[$? = 1]
$ cargo run shuf -er  # old, bad (unexpected success)
$ cargo run shuf -er  # new
shuf: no lines to repeat
[$? = 1]
```
2024-02-25 16:49:03 +01:00
Sylvestre Ledru
174864566e
Merge pull request #6006 from BenWiederhake/dev-tr-multi-arg
tr: Correctly handle multiple appearances of flag-args
2024-02-25 09:51:40 +01:00
Sylvestre Ledru
8301a8e5be
Merge pull request #5980 from BenWiederhake/dev-shuf-number-speed
shuf: Fix OOM crash for huge number ranges
2024-02-25 09:50:49 +01:00
Yury Zhytkou
17174ab986
uniq: pass remaining GNU tests (#5994) 2024-02-25 09:45:37 +01:00
Ben Wiederhake
f25b2102db shuf: document new benchmark category 2024-02-24 21:36:13 +01:00
Ben Wiederhake
445905a045 base32/base64/basenc: permit repeating -d/-i/-w flags 2024-02-24 21:11:18 +01:00
Ben Wiederhake
36e142aa15 basenc: use last given encoding, instead of priority list 2024-02-24 20:44:07 +01:00
Ben Wiederhake
44310f426c tr: enable passing -t multiple times 2024-02-24 18:37:45 +01:00
Ben Wiederhake
268af90843 tr: enable passing -s multiple times 2024-02-24 18:37:45 +01:00
Ben Wiederhake
352a8a5bd7 shuf: handle --input-range with huge number ranges
This requires special handling, because we cannot always generate all
possible strings beforehand, e.g. in the case of "-n 2 -i 0-2147483647".
2024-02-24 18:33:46 +01:00
Ben Wiederhake
989178f438 shuf: extract minimal required interface between data and core loop 2024-02-24 18:33:46 +01:00
Ben Wiederhake
dc664006fe tr: enable passing -d multiple times 2024-02-23 11:58:22 +01:00
Ben Wiederhake
cad94a69be tr: prevent passing options in the wrong place
Note: This requires using the DEPRECATED item Command::trailing_var_arg
in clap. This is going to be another
[problem with clap](https://github.com/tertsdiepraam/uutils-args/blob/main/docs/design/problems_with_clap.md).
2024-02-23 11:58:22 +01:00
Ben Wiederhake
d9b6675bbf tr: enable passing -c multiple times 2024-02-23 11:58:18 +01:00
Daniel Hofstetter
5a2e0c700e
Merge pull request #5990 from BenWiederhake/dev-shuf-head-null
shuf: Do not read input when -n0 is given
2024-02-23 09:01:14 +01:00
Ben Wiederhake
617f3a8b6f tr: when deleting and squeezing, never complement set2 2024-02-23 06:08:37 +01:00
Ben Wiederhake
48c4b57c97 tr: require second string argument when deleting and squeezing 2024-02-23 03:23:07 +01:00
Ben Wiederhake
a29f68b720 shuf: Do not read input when -n0 is given
This is explicitly tested by some suites, including the GNU test suite.
2024-02-22 23:50:03 +01:00
Ben Wiederhake
a59924ece5 shuf: treat -e as a flag, not as a multi-value arg 2024-02-22 23:22:35 +01:00
Sylvestre Ledru
f7821cd0d2
Merge pull request #5995 from cakebaker/factor_enable_debug_assert
factor: enable a debug_assert! statement
2024-02-22 16:51:54 +01:00
Daniel Hofstetter
999303e0d4 shuf: add missing word to BENCHMARKING.md 2024-02-22 15:13:54 +01:00
Daniel Hofstetter
4da633b835 factor: enable a debug_assert! statement 2024-02-22 09:33:29 +01:00
Daniel Hofstetter
725da985c1 Fix "item x imported redundantly" warnings 2024-02-19 15:39:37 +01:00
Terts Diepraam
177ac7ea28
stat: use chrono instead of time in fsext (#5934)
* stat: use chrono instead of time in fsext

This removes the dependency of `fsext` on `time` and it cleans up the code.

* stat: use chrono instead of time in fsext

This removes the dependency of `fsext` on `time` and it cleans up the code.

* stat: fix two errors from clippy & spell-checker

* stat: move fn to fix clippy error

* stat: print - if birth time unknown

* uucore/fsext: fix "unused import" error on Windows

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-02-19 10:21:26 +01:00
Sylvestre Ledru
9866f022a8
Merge pull request #5987 from tertsdiepraam/expand-remove-collect-ignore
`expand`: do not ignore invalid UTF-8
2024-02-18 15:19:47 +01:00
Terts Diepraam
913656be9d expand: do not ignore invalid UTF-8 2024-02-18 14:26:23 +01:00
Terts Diepraam
4da6d58a6b numfmt: remove clap workaround 2024-02-18 13:32:00 +01:00
Ben Wiederhake
b091911aae shuf: refuse multiple input ranges and multiple output files 2024-02-16 21:14:56 +01:00
Ben Wiederhake
69f23c2521 shuf: obey all headcount args, not just the last 2024-02-16 21:08:16 +01:00
Ben Wiederhake
07e8f4c7a5 shuf: include all echo args, not just the last 2024-02-16 20:49:59 +01:00
Daniel Hofstetter
420dfe8a9b
Merge pull request #5958 from tertsdiepraam/csplit-printf
`csplit`: use `printf` functionality from `uucore`
2024-02-16 14:39:03 +01:00
Terts Diepraam
fc82360f58 csplit: fix up tests and error message for filenames 2024-02-16 11:51:04 +01:00
Daniel Hofstetter
bfe6f0f004
Merge pull request #5979 from BenWiederhake/dev-shuf-null-input
shuf: Treat empty file as zero elements instead of one emptystring
2024-02-16 09:19:44 +01:00
David Matos
de74f707e9
uname: Refactor into public fns for Nushell (#5921)
* Refactor to use options struct and make it public for Nushell

* Return the output for use in nushell

* wip:opt1

* Add UNameOutput struct instead

* Apply req changes

* change back to mod options

* uname: add empty line & fix position of comment

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-02-16 08:53:36 +01:00
Ben Wiederhake
e54c9bebe2 shuf: Treat empty file as zero elements instead of one emptystring 2024-02-16 00:06:24 +01:00
Daniel Hofstetter
35141deeee ln: fix help text 2024-02-15 14:38:26 +01:00
Daniel Hofstetter
6adaf31d49
Merge pull request #5962 from wolimst/cut/fix/multiple-mode-args
cut: show error for multiple mode args (`-b`, `-c`, `-f`)
2024-02-14 14:23:47 +01:00
wolimst
6bec96aad1 cut: refactor mode args counting by removing nested map 2024-02-14 20:02:42 +09:00
BaherSalama
5603305e75
fix tr with any flag with more than 2 operands (#5952)
* fix tr

* add tests

* fix clippy

* fix clippy2

* do suggestions

* do suggestions

* remove mut

* tr: move var to block & remove its type

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-02-13 15:30:15 +01:00
Daniel Hofstetter
826cdbe3dc
Merge pull request #5940 from cre4ture/fix/stabilize_android_build_memory_kill_split
`split` fix android memory kill in split
2024-02-12 16:50:19 +01:00
Sylvestre Ledru
b4c8a1aee0
Merge pull request #5970 from cakebaker/ls_date_rename_duration_to_time_delta
ls,date: rename `chrono::Duration` to `chrono::TimeDelta`
2024-02-11 14:18:13 +01:00
Daniel Hofstetter
120a0e09fc ls,date: rename chrono::Duration to TimeDelta 2024-02-11 13:24:20 +01:00
Terts Diepraam
e0c2714d60 tsort: drastically reduce memory copies 2024-02-11 10:57:19 +01:00
Terts Diepraam
50cab572db uucore: ensure quoting-style feature is enabled if format is enabled 2024-02-10 21:37:28 +01:00
Ulrich Hornung
e68312cae9 sane blksize to avoid memory kill in split -n 3 /dev/zero 2024-02-10 14:33:13 +01:00
Terts Diepraam
a4f626efa2 uucore/format: refactor handling of flags to make clippy happy 2024-02-10 12:48:35 +01:00
Terts Diepraam
3a21d27c1e uucore/format: ignore the 0 flag if a precision is specified 2024-02-10 12:22:11 +01:00
Terts Diepraam
0602c197ff csplit: use uucore/format functionality for suffix 2024-02-10 11:51:20 +01:00
Terts Diepraam
a30dce0b7c uucore/format: cast signedint to unsignedint if possible 2024-02-10 11:51:20 +01:00
wolimst
0ac8606577 cut: add comments about handling multiple cutting mode args 2024-02-09 22:15:18 +09:00
Daniel Hofstetter
337bfeebc1 uucore/num_format: fix typo in comment 2024-02-09 13:28:18 +01:00
Terts Diepraam
3126e5f8a1 printf: fix padding and prefixes for unsigned ints 2024-02-09 13:28:18 +01:00
Terts Diepraam
4dae902429 printf: pad octal numbers with zeros on the left 2024-02-09 13:28:18 +01:00
wolimst
cb0ce0e1cb cut: show error for multiple mode args (-b, -c, -f) 2024-02-09 15:56:15 +09:00
Daniel Hofstetter
04ebd863a6 clippy: fix warnings introduced by Rust 1.76 2024-02-08 16:56:01 +01:00
BaherSalama
5c2ae5be4f
fix tr with delete flag if more than 1 operand given (#5945)
* fix tr

* fix

* adding a test

* tr: rename test function

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-02-06 16:42:08 +01:00
Terts Diepraam
0b89a734b6 uucore: make help_{about,usage} fail if no text is found 2024-02-06 13:45:43 +01:00
Terts Diepraam
64cb591e3b seq: fix about text not found 2024-02-06 13:45:12 +01:00
Daniel Hofstetter
d2a75457f6 Fix errors reported by new version of cspell 2024-02-05 09:12:52 +01:00
Ludmuterol
96d96e7de3
more handle errors with multiple files (#4997)
* more handle errors with multiple files

* tests/more test refactor and new case

* tests/more new cases

* more: use show! and change exitstatus and adjust tests to new exitvalue

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2024-02-04 16:32:14 +01:00
Ulrich Hornung
93d922f075
squash commit 2024-02-03 17:08:39 +01:00
Sylvestre Ledru
b485a480cf
Merge pull request #5932 from cakebaker/uucore_fix_never_used_warnings_on_redox
uucore: fix "X is never used" warnings on Redox
2024-02-03 07:46:29 +01:00
Biplab Mochan Gartia
fd4e1cfb28
stat: should fail without arguments #5928 (#5935)
* stat: should fail without arguments #5928

* style and lint issue  stat: should fail without arguments #5928

* style and lint issue  stat: should fail without arguments #5928

* style and lint 2 issue  stat: should fail without arguments #5928

---------

Co-authored-by: biplab5464 <biplab5464@outlook.com>
2024-02-02 17:00:35 +01:00
Samuel Larkin
c7f730470f doc: fixed benchmark table 2024-02-02 10:13:38 -05:00
Daniel Hofstetter
9c7675945f uucore: fix "X is never used" warnings on Redox 2024-02-02 09:33:35 +01:00
Daniel Hofstetter
47843dc8f5 ls: fix "unused variable" warning on Redox 2024-02-02 09:13:38 +01:00
Biplab Mochan Gartia
4a7dfa7904
stat.rs: Refactor to remove #[allow(clippy::cognitive_complexity)] #5881 (#5924)
* stat.rs: Refactor to remove #[allow(clippy::cognitive_complexity)] #5881

* remvoe Vec when ruturing  stat.rs: Refactor to remove #[allow(clippy::cognitive_complexity)] #5881

* formmating issue  stat.rs: Refactor to remove #[allow(clippy::cognitive_complexity)] #5881

* cakebaker suggestion stat.rs: Refactor to remove #[allow(clippy::cognitive_complexity)] #5881

* sytle and lint issue  stat.rs: Refactor to remove #[allow(clippy::cognitive_complexity)] #5881

---------

Co-authored-by: biplab5464 <biplab5464@outlook.com>
2024-02-01 16:20:32 +01:00
Daniel Hofstetter
d53077160f
Merge pull request #5914 from Ideflop/disable-row-mode-on-panic
more: Disable raw mode before exiting if a panic occurs
2024-02-01 15:08:08 +01:00
Ideflop
b9112da4b2 more: Disable raw mode before exiting if a panic occurs 2024-01-30 20:57:38 +01:00
Sylvestre Ledru
8691ec9a80
Merge pull request #5916 from cakebaker/du_non_existing
du: adapt error message to match GNU's
2024-01-30 17:13:37 +01:00
Sudhakar Verma
bd336ebbf1 dd: fail on missing number in count 2024-01-30 20:21:25 +05:30
Daniel Hofstetter
d1e1e9ce0f du: adapt error msg to match GNU's 2024-01-30 10:08:50 +01:00
Terts Diepraam
1b324da436 echo: do not infer long args 2024-01-29 17:40:22 +01:00
Daniel Hofstetter
742d39300b wc: fix two incorrect code comments 2024-01-29 10:42:34 +01:00
Harsh Ranjan
1528b35113
refactor wc.rs to remove clippy's cognitive complexity lint (#5897)
* refactor wc.rs to remove clippy's cognitive complexity lint

* fix for tracking line length and number of words correctly if chunking occurs within them

* removing more of the cognitive complexity from the Err variant in the match block

* running cargo clippy once

* wc: add empty line to separate functions

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-01-29 10:41:11 +01:00
Jeffrey Finkelstein
d782fd1bd3 dd: parse big numbers and return u64::MAX
Change the behavior of `dd` so that it parses numbers that would be too
big and instead treats them as `u64::MAX`. This allows `dd` to run
without error on

    dd count=00x9999999999999999999999999999999999999999999999999999999999999

This matches the behavior of GNU `dd`.
2024-01-28 13:41:34 -05:00
kralo
ee7f99aad0 cp: use inclusive range
as suggested by clippy::range-plus-one
2024-01-28 09:42:40 +01:00
kralo
d046d33bee split: use inclusive range
as suggested by clippy::range-plus-one
2024-01-28 09:42:40 +01:00
kralo
9906e66096 uucore: remove unneccessary closues
This adresses only those where the fix has less letters than the
original and is "trivial" (There are possibly a lot of std::string::ToString::to_string
and those may only be shortened with additional imports).

Found with clippy::redundant-closure-for-method-calls
2024-01-28 09:42:40 +01:00
kralo
bd43a7ed99 nl: fix redundant clone (clippy warning) 2024-01-28 09:42:40 +01:00
Sylvestre Ledru
7fa4b389a9
Merge pull request #5892 from kralo/fix-5883
factor: rename input parameter
2024-01-28 09:28:36 +01:00
kralo
9adceb4f65 factor: rename input parameter
Closes: #5883
2024-01-28 08:24:16 +01:00
kralo
12dd1e4d7d cp: remove lint exceptions
Could not even reproduce what they would complain for.
Closes: #5885
2024-01-27 19:21:05 +01:00
kralo
3eba95728c factor: remove clippy exceptions by reformatting "unreadable literals"
Closes: #5884
2024-01-27 17:23:44 +01:00
Daniel Hofstetter
c8cd355708 cut: set exit code to 1 if dir is specified 2024-01-26 10:18:44 +01:00
Daniel Lungu
61c730d1b3
expand: Continue work when one of given files doesn't exist (#5873)
* expand: continues work when one of given files doesn't exist

* fixed test for nonexisting file
2024-01-25 09:10:59 +01:00
Sylvestre Ledru
1693640446 whoami: add missing feature 2024-01-24 21:33:25 +01:00
Biplab Mochan Gartia
150b287fe8
unexpand: allow multiple files & show error message if a directory is specified
* unexpand: should allow multiple files #5852 and unexpand: show error message if a directory is specified #5845

* test file added for #5845 #5852

* test case test_multiple_files improve

* cakebaker suggestion for a better code #5845 #5852

---------

Co-authored-by: biplab5464 <biplab5464@outlook.com>
2024-01-24 16:01:26 +01:00
Daniel Hofstetter
d690e8fb99
Merge pull request #5752 from sylvestre/0.0.24
0.0.23 => 0.0.24
2024-01-21 13:35:10 +01:00
Sylvestre Ledru
dd5c6c2d00 0.0.23 => 0.0.24 2024-01-20 20:12:19 +01:00
Sylvestre Ledru
5e29c60b26 hashsum: when the filename contains some special chars, escape them
Should fix tests/cksum/md5sum-newline.pl
2024-01-20 19:27:45 +01:00
SaHHiiLL
746a7b14d0
tsort: returns error when input is dir - same as GNU tsort (#5860)
* fix: return error when input is dir

* test: when tsort is given a dir

* fix: do not need to mention tsort in error message

* test: using concrete directory name

* tsort: fix formatting in test

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-01-19 15:39:00 +01:00
Sylvestre Ledru
b7a14ac119
Merge pull request #5825 from tertsdiepraam/codecov-uucore-features
CI: test `uucore` with `coreutils` in codecov to run it with the proper features
2024-01-17 11:51:02 +01:00
Terts Diepraam
61de1dc23a uucore/sum: fix crlf test 2024-01-17 10:44:33 +01:00
Terts Diepraam
3bd9f0ec65
Merge pull request #5811 from spineki/fix-printf-hex-alternate-zero
Printf: Fix printf hex alternate zero
2024-01-17 10:28:30 +01:00
Ulrich Hornung
dc533a915a
install: fix strip program stdout and destination hyphen handling #5718 (#5848)
* Fix missing dependency to "process" to make it compile.

* fix issue of not forwarding stdout from strip program

* fix issue of applying "./" redundantly

* cargo fmt
2024-01-17 10:07:34 +01:00
Sylvestre Ledru
3872aca9c6 spell: ignore getxattr 2024-01-16 13:12:02 +01:00
Sylvestre Ledru
66637a6503 move the file_has_acl function into uucore 2024-01-16 13:12:02 +01:00
Sylvestre Ledru
2ec4e9f784 mv: preserve the xattr
Should make tests/mv/acl pass
2024-01-16 13:12:02 +01:00
Sylvestre Ledru
fe3f8293ef uucore: add a new feature called fsxattr 2024-01-16 13:11:58 +01:00
Daniel Hofstetter
112eb21eb3
Merge pull request #5791 from sylvestre/handle-error
Handle better some errors
2024-01-15 15:19:10 +01:00
Sylvestre Ledru
fff83995fb
cp: --preserve should keep xattr (#5834)
* cp: --preserve should keep xattr

Should help with tests/cp/acl.sh

* Update tests/by-util/test_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>

* 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>
2024-01-15 10:59:04 +01:00
Sylvestre Ledru
4557821adf
Merge branch 'main' into fix-printf-hex-alternate-zero 2024-01-15 10:41:09 +01:00
Sylvestre Ledru
e340d8177e
Merge pull request #5842 from cakebaker/uucore_fix_clippy_warning
uucore: fix clippy warning from if_not_else lint
2024-01-15 10:40:23 +01:00
Daniel Hofstetter
e91540fc07 uucore: fix clippy warning from if_not_else lint 2024-01-15 10:27:59 +01:00
Biplab Mochan Gartia
076b905513
cksum: stops when one of given files doesn't exist #5809 (#5820)
* cksum: stops when one of given files doesn't exist #5809

* removed printld  cksum: stops when one of given files doesn't exist #5809

* formatting the code cksum: stops when one of given files doesn't exist #5809

* formatting the code cksum: stops when one of given files doesn't exist #5809

* set exist status cksum: stops when one of given files doesn't exist #5809

* code quality formatting issue cksum: stops when one of given files doesn't exist #5809

* tertsdiepraam idea cksum: stops when one of given files doesn't exist #5809

* one new test case and deleted duplicate show cksum: stops when one of given files doesn't exist #5809

* formatting the test cases cksum: stops when one of given files doesn't exist #5809

* Revert "formatting the test cases cksum: stops when one of given files doesn't exist #5809"

This reverts commit 8c382f1e8f.

* reverting the changes and committing again due to a mistake cksum: stops when one of given files doesn't exist #5809

---------

Co-authored-by: biplab5464 <biplab5464@outlook.com>
2024-01-15 09:37:56 +01:00
Sylvestre Ledru
36039a819d
Merge pull request #5739 from cakebaker/cp_backup_with_symlink_to_source
cp: backup dest symlink linking to source
2024-01-14 23:30:06 +01:00
Sylvestre Ledru
e3beda08ac
Merge pull request #5762 from cakebaker/cp_link_same_file
cp: show no "same file" error for `--link a a`
2024-01-14 23:29:33 +01:00
Sylvestre Ledru
ef03a4625f
Merge pull request #5806 from cakebaker/nl_is_a_directory
nl: don't exit if input is directory
2024-01-14 23:29:05 +01:00