Commit graph

1380 commits

Author SHA1 Message Date
Jeffrey Finkelstein
664c7a6ec5 tac: add support for --regex option to tac
Add support for `tac --regex`, where the line separator is interpreted
as a regular expression.
2021-09-11 22:54:55 -04:00
Olivier EBLÉ
872c0fac1d
tests/kill: test old form args with signal name
Add two tests of the old form signal arg using the signal name instead
of the number.

Bonus: add a test for the new form but with the prefix SIG-
2021-09-11 22:37:55 +02:00
Jan Scheer
e018a45b54
test_ls: add/adjust tests for SELinux context 2021-09-11 04:13:30 +02:00
Jeffrey Finkelstein
96b8616a1a seq: use stdout.write_all() instead of print!()
Change from using `print!()` to using `stdout.write_all()` in order to
allow the main function to handle broken pipe errors gracefully.
2021-09-10 20:00:26 -04:00
Jan Verbeek
b7d697753c unlink: Simplify, remove unsafe, move to core
This makes it no longer possible to pass multiple filenames, but every
other implementation I tried (GNU, busybox, FreeBSD, sbase) also
forbids that so I think it's for the best.
2021-09-10 21:50:38 +02:00
Jan Verbeek
8f901ee860 tty: Make test_stdout_fail() less flaky 2021-09-10 19:29:27 +02:00
Jan Scheer
46fc91af19
test_ls: add features for uutils called by ccmd 2021-09-10 18:36:51 +02:00
Sylvestre Ledru
75e5c42e40
chown: support '.' as 'user.group' separator (like ':') (#2638)
* chown: support '.' as 'user.group' separator (like ':')

It also manages the case:
user.name:group (valid too)

Should fix:
gnu/tests/chown/separator.sh
2021-09-10 08:15:23 +02:00
Sylvestre Ledru
ed258e3c9c
touch: add --ref as an alias (#2641) 2021-09-09 21:48:17 +02:00
Michael Debertol
2170d81621
Merge pull request #2633 from blyxxyz/update-quoting
Update filename quoting and printing
2021-09-09 20:42:00 +02:00
Jan Scheer
cd0d23752a
tail: add fixes to pass "gnu/tests/tail-2/tail-c.sh" from GNU's test suite 2021-09-08 13:10:19 +02:00
Jan Verbeek
1ef2574b08 Replace backtick quoting 2021-09-07 20:16:45 +02:00
Jan Verbeek
741f065a12 test_ls: Fix clippy warnings 2021-09-07 19:49:01 +02:00
Jan Verbeek
259f18fcab Update message quoting and filename printing 2021-09-07 19:49:01 +02:00
Sylvestre Ledru
a0be9811c6
Merge pull request #2513 from drocco007/test-parentheses
test: handle additional parentheses edge cases
2021-09-06 22:23:21 +02:00
James Robson
625c3f2330 Add -e/-m to realpath 2021-09-05 22:50:23 +02:00
Sylvestre Ledru
9c22def693 cp: ignore test_no_preserve_mode & test_preserve_mode 2021-09-05 18:54:43 +02:00
Sylvestre Ledru
f8c4b56174 Remove comment on test_chown_only_group_id 2021-09-05 18:54:43 +02:00
Sylvestre Ledru
99764b8e6e Add "cuuser" to the spell ignore in tests 2021-09-05 18:54:43 +02:00
Sylvestre Ledru
1986d346dc Silent 'test_more_than_2_sets' on freebsd 2021-09-05 18:54:43 +02:00
Sylvestre Ledru
00221a4d36 Silent test_chown_only_group_id on freebsd 2021-09-05 18:54:43 +02:00
Mahmoud Soltan
9bc14a239c
Added support for ls -l --color to color symlink targets as well. (#2627)
* Fixed some documentation of display_item_long that was missed in #2623

* Implemented coloring of `ls -l` symlink targets( after the arrow `->`).

* Documented display_file_name to some extent.

* Ran rustfmt as part of mitigating CI chain errors.

* Removed unused variables and code in test_ls_long_format as per #2623

specifically, as per
https://github.com/uutils/coreutils/pull/2623#pullrequestreview-742386707

* Added a thorough test for `ls -laR --color` symlink coloring implemented in this branch.

* renamed test files and dirs to shorter names and ran rustfmt.

* Changed the order with which files are expected to match the change in their name.

* Bettered some comments.

* Removed needless borrow. Fixed that one clippy warning.

* Moved the cfg not windows up to the function level

because this function is meant to only run in non-windows OS (with
groups and unames).

Fixes the unused variable warning in CI.
2021-09-05 13:25:56 +02:00
Sylvestre Ledru
6226a03214
Merge pull request #2624 from miDeb/cp/acl
cp: correctly copy mode, ownership, acl and context
2021-09-03 20:18:13 +02:00
Michael Debertol
6a6da71403 cp: add a test for #2631 2021-09-03 14:56:35 +02:00
Michael Debertol
a7f6b4420a uucore/perms: take traverse_symlinks into account 2021-09-03 00:50:04 +02:00
Michael Debertol
18fc4076cf uucore/perms: correct some error messages
- prevent duplicate errors from both us and `walkdir` by instructing `walkdir'
  to skip directories we failed to read metadata for.
- don't directly display `walkdir`'s errors, but format them ourselves to
  match gnu's format
2021-09-01 18:40:06 +02:00
Michael Debertol
a517671d55
Merge pull request #2621 from blyxxyz/filename-quoting
Implement proper quoting/escaping for filenames
2021-09-01 14:15:44 +02:00
Michael Debertol
8b74562820 cp: correctly copy mode, ownership, acl and context
Fix a mix-up between ownership and mode. The latter (mode / file permissions)
can also be set on windows (which however only affects the read-only flag),
while there doesn't seem to be a straight-forward way to change file ownership
on windows.

Copy the acl as well when copying the mode. This is a non-default feature and can be
enabled with --features feat_acl, because it doesn't seem to work on CI.
It is only available for unix so far.

Copy the SELinux context if possible.
2021-09-01 00:16:22 +02:00
Justin Tracey
575fbd4cb7 join: make autoformat actually construct a format
Makes the -o auto option construct a format at initialization, rather
than try to handle it as a special case when printing lines. Fixes bugs
when combined with -e, especially when combined with -a.
2021-08-31 23:55:15 +02:00
Jan Verbeek
7ca2f4989f ls: Hide unused variable warnings 2021-08-31 22:07:24 +02:00
Jan Verbeek
4d6faae555 ls: Fix --{show, hide}-control-chars logic 2021-08-31 22:07:24 +02:00
Mahmoud Soltan
97a0c06ff4
Proper columns for ls -l (#2623)
* Used .as_path() and .as_str() when required:

when the argument required is a Path and not a PathBuf,
or an str and not a Path, respectively.

* Changed display_items to take Vec<PathData>, which is passed, instead of [PathData]

* Added a pad_right function.

* Implemented column-formating to mimic the behavior of GNU coreutils's ls

Added returns in display_dir_entry_size that keep track of uname and
group lengths.
Renamed variables to make more sense.
Changed display_item_long to take all the lengths it needs to render
correctly.
Implemented owner, group, and author padding right to mimic GNU ls.

* Added a todo for future quality-of-life cache addition.

* Documented display_item_long, as a first step in documenting all functions.

* Revert "Used .as_path() and .as_str() when required:"

This reverts commit b88db6a817.

* Revert "Changed display_items to take Vec<PathData>, which is passed, instead of [PathData]"

This reverts commit 0c690dda8d.

* Ran cargo fmt to get rid of Style/format `fmt` testing error.

* Added a test for `ls -l` and `ls -lan` line formats.

* Changed uname -> username for cspell. Removed extra blank line for rustfmt.
2021-08-30 23:09:16 +02:00
Jeffrey Finkelstein
5cd55391ec seq: compute width of numbers after parsing
Fix a bug in `seq` where the number of characters needed to print the
number was computed incorrectly in some cases. This commit changes the
computation of the width to be after parsing the number instead of
before, in order to accommodate inputs like `1e3`, which requires four
digits when printing the number, not three.
2021-08-28 17:43:36 -04:00
Sylvestre Ledru
64a65370b0
Merge pull request #2611 from sylvestre/freebsd-warnings
Remove some warnings on freebsd
2021-08-28 23:24:24 +02:00
Jan Verbeek
b4c95d49d8
pwd: Properly resolve logical working directory (#2604)
* pwd: Properly resolve logical working directory

* fixup! pwd: Properly resolve logical working directory

* fixup! pwd: Properly resolve logical working directory
2021-08-28 22:31:20 +02:00
Sylvestre Ledru
2c3e401b0b Remove some warnings on freebsd 2021-08-28 15:06:44 +02:00
Sylvestre Ledru
85c7178b10
Merge pull request #2609 from jfinkels/seq-negative-zero-start
seq: print negative zero at start of integer sequence
2021-08-28 12:32:50 +02:00
Sylvestre Ledru
0e49913b84
Merge branch 'master' into chmod/compat 2021-08-28 11:21:26 +02:00
Sylvestre Ledru
33055f7152
Merge pull request #2597 from miDeb/resolve-dangling
uucore/fs: use the latest resolution that did not fail
2021-08-28 09:55:44 +02:00
Jeffrey Finkelstein
2c66d9e0a7 seq: print negative zero at start of integer seq. 2021-08-27 21:44:09 -04:00
Jan Verbeek
afb460f4ca rmdir: match GNU
- Implement all of GNU's fiddly little details
- Don't assume Linux for error codes
- Accept badly-encoded filenames
- Report errors after the fact instead of checking ahead of time
- General cleanup

rmdir now passes GNU's tests.
2021-08-28 02:26:01 +02:00
Jan Verbeek
f50b004860 wc: Adjust expected report for directories for Windows 2021-08-26 01:38:16 +02:00
Jan Verbeek
4943517327 wc: Adjust expected error messages for Windows 2021-08-26 01:38:16 +02:00
Jan Verbeek
0f1e79fe29 wc: Fix linters 2021-08-26 01:38:16 +02:00
Jan Verbeek
c16e492cd0 wc: Make output width more consistent with GNU 2021-08-26 01:38:16 +02:00
Jan Verbeek
d0c0564947 wc: Swap order of characters and bytes in output
This way it matches GNU and busybox.
2021-08-26 01:38:16 +02:00
Jan Verbeek
657a04f706 wc: Stricter simpler error handling
Errors are now always shown with the corresponding filename.

Errors are no longer converted into warnings. Previously `wc < .`
would cause a loop.

Checking whether something is a directory is no longer done in
advance. This removes race conditions and the edge case where stdin is
a directory.

The custom error type is removed because io::Error is now enough.
2021-08-26 01:38:16 +02:00
Jan Verbeek
6f7d740592 wc: Do a chunked read with proper UTF-8 handling
This brings the results mostly in line with GNU wc and solves nasty
behavior with long lines.
2021-08-26 01:38:16 +02:00
Michael Debertol
5121e2eec1 chmod: add check for quiet 2021-08-25 13:52:09 +02:00
Michael Debertol
5825889931 chmod: correctly handle modes after -- 2021-08-25 13:52:09 +02:00
Michael Debertol
b841a11421 chmod: fail if the operand list is empty 2021-08-25 13:52:09 +02:00
Michael Debertol
945e57ea22 chmod: show an error if a permission wasn't removed due to umask 2021-08-25 13:52:09 +02:00
Michael Debertol
15b40f6aa2 chmod: implement special handling of directory setuid/setgid 2021-08-25 13:52:09 +02:00
Michael Debertol
74958794c6 chmod: print change message to stdout, not stderr 2021-08-25 13:52:09 +02:00
Michael Debertol
080998b6ef chmod: pad all file modes to 4 digits 2021-08-25 13:52:09 +02:00
Jan Verbeek
e5d6c6970b yes: Cleanup
Report errors properly instead of panicking.

Replace zero_copy by a simpler specialized private module.

Do not assume splices move all data at once.

Use the modern uutils machinery.

Remove the "latency" feature. The time it takes to prepare the buffer
is drowned out by the startup time anyway.

yes: Add tests

yes: Fix long input test on Windows
2021-08-25 13:45:44 +02:00
Michael Debertol
ea41cc0ff6 uucore/fs: use the latest resolution that did not fail
When we ignore failures resolving symbolic links we should keep the
latest resolution that did not fail, not the original path.
2021-08-24 21:18:10 +02:00
Michael Debertol
7153a595c6 chgrp: forward to chown
chgrp does mostly the same as chown.
By making chown a bit more configurable we can reuse its code for chgrp.
2021-08-24 15:22:05 +02:00
Sylvestre Ledru
68c9bfa658
Merge pull request #2581 from sylvestre/freebsd
Use github action for FreeBSD testing and remove cirrus CI
2021-08-24 14:47:34 +02:00
Michael Debertol
91a8f533b6
Merge pull request #2582 from jfinkels/tac-multi-char-separator-overlap
tac: support multi-character line separator with possible overlaps
2021-08-24 12:03:45 +02:00
Jan Verbeek
516c5311f7
Close file descriptors of pipes after use (#2591)
* Close file descriptors of pipes after use

* cat: Test file descriptor exhaustion

* fixup! cat: Test file descriptor exhaustion
2021-08-24 12:00:07 +02:00
Sylvestre Ledru
697dca25cb silent the failed tests for now on freebsd 2021-08-24 09:32:27 +02:00
Sylvestre Ledru
78e28060a0 NORMAL_FORMAT_STR is also used for freebsd 2021-08-24 09:32:27 +02:00
Jeffrey Finkelstein
0e689e78aa tac: support multi-char separator with overlap
Fix a bug in `tac` where multi-character line separators would cause
incorrect behavior when there was overlap between candidate matches in
the input string. This commit adds a dependency on `memchr` in order to
use the `memchr::memmem::rfind_iter()` function to scan for
non-overlapping instances of the specified line separator characters,
scanning from right to left.

Fixes #2580.
2021-08-23 20:16:38 -04:00
jfinkels
bdc0f4b7c3
hashsum: support --check for algorithms with variable output length (#2583)
* hashsum: support --check for var. length outputs

Add the ability for `hashsum --check` to work with algorithms with
variable output length. Previously, the program would terminate with an
error due to constructing an invalid regular expression.

* fixup! hashsum: support --check for var. length outputs
2021-08-23 18:35:19 +02:00
Sylvestre Ledru
9f3debeda3
Merge pull request #2534 from jfinkels/basename-handle-slashes
basename: handle paths comprising only slashes
2021-08-22 22:49:30 +02:00
Koutheir Attouchi
7010dfd939 runcon: added implementation and tests. 2021-08-22 21:59:41 +02:00
jfinkels
4ef35d4a96
tac: correct behavior of -b option (#2523)
* tac: correct behavior of -b option

Correct the behavior of `tac -b` to match that of GNU coreutils
`tac`. Specifically, this changes `tac -b` to assume *leading* line
separators instead of the default *trailing* line separators.

Before this commit, the (incorrect) behavior was

    $ printf "/abc/def" | tac -b -s "/"
    def/abc/

After this commit, the behavior is

    $ printf "/abc/def" | tac -b -s "/"
    /def/abc

Fixes #2262.

* fixup! tac: correct behavior of -b option

* fixup! tac: correct behavior of -b option

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2021-08-22 21:01:17 +02:00
Sylvestre Ledru
114c9a409c
Merge pull request #2471 from miDeb/real-exe-name
make executable!() return the real executable name
2021-08-22 16:55:06 +02:00
Jeffrey Finkelstein
fbb81f7088 tests(head): change file mode from 755 to 644 2021-08-21 22:59:59 -04:00
Michael Debertol
5e07d58a4d
Merge pull request #2459 from jaggededgedjustice/realpath-add-physical-mode
Add Physical mode to realpath
2021-08-21 02:01:10 +02:00
Michael Debertol
0062e54b5e test_util_name: symlink the xecutable instead of copying
Speculative fix for "text file busy" errors.
2021-08-20 00:20:56 +02:00
Michael Debertol
5f2335829a refactor ~ revert to single quotes for "Try '{0 --help'"
This is a test expectation for gnu.
2021-08-14 17:22:09 +02:00
Michael Debertol
44981cab01 refactor/uucore ~ correct implementation of executable!() for multicall
- Use an atomic bool to track whether the utility name is the second
or the first argument.
- Add tests
2021-08-14 14:01:34 +02:00
Roy Ivy III
4da46d93c7 tests ~ fix tests for new execution_phrase!() and usage phrasing 2021-08-14 14:01:34 +02:00
Terts Diepraam
f9559fea80
Merge pull request #2569 from jtracey/master
join: add support for full outer joins
2021-08-13 14:38:15 +02:00
Justin Tracey
1bb0237281 join: add support for full outer joins 2021-08-12 23:52:35 -04:00
Sylvestre Ledru
a7797c01c0
Merge branch 'master' into chgrp/no-err 2021-08-13 01:35:21 +02:00
Sylvestre Ledru
8f55c79c9b
Merge pull request #2566 from miDeb/ls/width
ls: correct output width
2021-08-13 01:31:52 +02:00
Sylvestre Ledru
f98415051b
Merge pull request #2567 from miDeb/pr/tests
pr: reduce test flakiness
2021-08-13 01:30:19 +02:00
Michael Debertol
ce1323ce1c cp: do not set the current directory in tests
Setting the current directory in tests affects other tests, even if the
change is reverted after, because tests are run in parallel.

This should fix the flaky cp tests.
2021-08-12 22:42:40 +02:00
Michael Debertol
1725bf6a36 pr: reduce test flakiness
Since some tests run multiple commands, we have to re-calculate the
expected result for every run.
This is because the expected results depend on file timestamps, but the
files are re-created for every new TestScenario.
2021-08-12 17:03:06 +02:00
Michael Debertol
0af244ac42 ls: default to one-line output if stdout is not a tty 2021-08-11 22:03:41 +02:00
Michael Debertol
988cc49d4a ls: print a single line when width is set to 0
This means that we treat a width=0 as infinite width.
2021-08-11 19:12:45 +02:00
Michael Debertol
13a62489c5 ls: correct fallbacks for terminal width
If options::WIDTH is not given, we should try to use the terminal width.
If that is unavailable, we should fall back to the 'COLUMNS' environment variable.
If that is unavailable (or invalid), we should fall back to a default of 80.
2021-08-11 19:12:37 +02:00
Michael Debertol
1c30fb42d2 chgrp: handle empty group 2021-08-11 19:03:41 +02:00
Michael Debertol
0edc9b01b9 factor: prevent writing incomplete lines
This makes it possible to execute multiple `factor` instances that write
to the same output in parallel, without having them interfere.
2021-08-10 00:14:51 +02:00
Sylvestre Ledru
966cf79747
Merge pull request #2551 from uutils/od-hang
od: fix reading from file while supplying a format argument
2021-08-09 12:36:31 +02:00
Sylvestre Ledru
ee98efd92e
Merge pull request #2552 from miDeb/cat/show-crlf
cat: show `\r\n` as `^M$` when `-E` is enabled
2021-08-09 12:23:59 +02:00
Michael Debertol
312e1ce9e0 chgrp: don't output an empty error 2021-08-09 01:33:02 +02:00
Michael Debertol
03ceb6750e cat: check if the input file is also the output file 2021-08-08 01:32:22 +02:00
Michael Debertol
7229360217 cat: remove all per-file state
cat cannot keep per-file state, so move all remaining state (one_blank_kept)
to the global state.
2021-08-07 23:04:25 +02:00
Michael Debertol
5be4c48546 cat: show \r\n as ^M$ when -E is enabled
This functionality was recently added to GNU cat, but had a bug.
This implementation will be commpatible with gnu once the bug in gnu is fixed.
2021-08-07 21:18:15 +02:00
Jeremy Soller
6af3f774f1
od: fix reading from file while supplying a format argument
The following test case read stdin instead of file:
```
echo abcdefg > file
cargo run -- od --format x1 file
```

This is because the -t/--format argument was able to absorb multiple
arguments after it. This has now been fixed, and a test case is added
to ensure it will not happen again.
2021-08-06 15:07:38 -06:00
Sylvestre Ledru
32d281bbcc
Merge pull request #2544 from miDeb/sort/delete-tmps
sort: delete temporary files when sort is terminated
2021-08-06 11:52:06 +02:00
Michael Debertol
0ae9e10ed3 sort: delete the temporary directory when sort is terminated
When hitting Ctrl+C sort now deletes any temporary files. To make this easier I
created a new struct `TmpDirWrapper` that handles the creation of new temporary
files and the registration of the signal handler.
2021-08-06 11:29:24 +02:00
Sylvestre Ledru
50b9d9f9a3
Merge branch 'master' into master 2021-08-06 09:26:39 +02:00
Koutheir Attouchi
090be5bb94 chcon: added implementation and integration tests
The ToDo list was updated to mark `chcon` as done.

Building and testing `chcon` requires enabling the `feat_selinux` feature. If `make` is used for building, then please specify `SELINUX_ENABLED=1` if building and testing on a system where SELinux is not enabled.
2021-08-05 22:57:57 -04:00
Michael Debertol
b8c383e210 basenc: add utility
basenc is a brand-new gnu core utility (added less than 3 years ago!),
which enables some more encodings.
2021-08-06 00:07:19 +02:00
backwaterred
2c41838166
Merge branch 'uutils:master' into master 2021-08-04 12:47:47 -07:00
Tyler
0864234e3d Removes unused macros from windows & macos builds 2021-08-04 12:47:03 -07:00
Tyler
601c9fc620 Merge branch 'master' of https://github.com/uutils/coreutils into uutils-master-2 2021-08-03 17:33:43 -07:00
Michael Debertol
9700f0503d base32/64: adjust error message to match gnu 2021-08-04 00:04:25 +02:00
Michael Debertol
44ae927969 base32/64: print the first extra operand, not the one before
Only one operand is allowed, so when there are multiple arguments we
should print the second argument in the error.
2021-08-03 23:37:20 +02:00
Sylvestre Ledru
26cc2ed440
Merge pull request #2517 from jfinkels/tac-null-separator
tac: support null separator (-s "")
2021-08-03 09:22:50 +02:00
Sylvestre Ledru
afb2e422fd
Merge pull request #2529 from jfinkels/tests-improve-link-arg-names
tests: better arg names in link helper functions
2021-08-03 09:21:36 +02:00
Jan Scheer
010565c8fb
Merge branch 'master' into id_selinux_context 2021-08-02 10:40:45 +02:00
Jeffrey Finkelstein
2a4c0a867a tests: better arg names in link helper functions
Change the argument names in

* `AtPath::hard_link()`,
* `AtPath::symlink_file()`, and
* `AtPath::symlink_dir()`,

from `src` and `dest` to `original` and `link` to match the arguments of
the corresponding functions from the Rust standard library. For example,
see `std::os::unix::fs::symlink()`.
2021-08-01 19:50:58 -04:00
Jeffrey Finkelstein
d74fb62df7 tac: support null separator 2021-08-01 19:47:21 -04:00
Sylvestre Ledru
24b1822cba
Merge pull request #2468 from thomasqueirozb/tail_stdin
tail: handle `-` as an alias for stdin
2021-08-02 00:24:28 +02:00
Thomas Queiroz
6127ea9642 tests/tail: add test for as an alias for stdin 2021-08-01 17:20:30 -04:00
James Robson
0e04f959c2 Add Physical mode to realpath
This adds the 'Physical Mode' and 'Logical Mode' switches to realpath, which control when symlinks are resolved.
2021-08-01 17:06:09 +01:00
Michael Debertol
450a487d76 sort: ignore broken pipes in a test
Since sort exits early due to the nonexistent file, it might no longer
be around when we try to send it the input.
This is "by design" and can be ignored.
2021-08-01 18:02:52 +02:00
Michael Debertol
af47c66a00 sort: improve tests 2021-08-01 17:12:35 +02:00
Jeffrey Finkelstein
8f5b785180 fixup! basename: handle paths comprising only slashes 2021-08-01 10:05:01 -04:00
Sylvestre Ledru
2d84c68f20
Merge branch 'master' into sort/input-is-output 2021-08-01 13:51:19 +02:00
Jeffrey Finkelstein
0d348f05f2 basename: handle paths comprising only slashes
Fix an issue where `basename` would print the empty path when provided
an input comprising only slashes (for example, "/" or "//" or
"///"). Now it correctly prints the path "/".
2021-07-31 18:57:02 -04:00
Michael Debertol
663c9751a1 sort: do not exit with failure for "--version" or "--help" 2021-08-01 00:05:08 +02:00
Michael Debertol
418f5b7692 sort: handle empty merge inputs 2021-07-31 21:02:20 +02:00
Michael Debertol
5bf4536bdd sort: ignore failure to truncate the output file 2021-07-31 21:02:20 +02:00
Michael Debertol
849086e9c5 sort: handle cases where the output file is also an input file
In such cases we have to create a temporary copy of the input file to prevent
overwriting the input with the output. This only affects merge sort, because it
is the only mode where we start writing to the output before having read all inputs.
2021-07-31 21:02:18 +02:00
Sylvestre Ledru
103a9d52ff
Merge pull request #2521 from miDeb/sort/rand
sort: improve compatibility of --random-sort
2021-07-31 21:00:18 +02:00
Michael Debertol
3564dc5792 sort: compare strings before comparing hashes
Since lines that compare equal should be sorted together, we need to first
compare the lines (taking settings into account). Only if they do not compare
equal we should compare the hashes.
2021-07-31 20:07:05 +02:00
Michael Debertol
f851fb6454 sort: initialize the salt when the random setting is on a key as well
Additionall, change the type of `salt` from `String` to `Option<[u8; 16]>`.
2021-07-31 20:07:05 +02:00
Michael Debertol
095e53aed2 sort: disallow equal lines for --check with --unique 2021-07-31 19:57:41 +02:00
Sylvestre Ledru
6b73ddcd12 Silent the spell checker on a test examples 2021-07-31 10:38:32 +02:00
Sylvestre Ledru
1eb3b62c46
Merge pull request #2537 from jfinkels/expand-improve-tabs-argument-2
expand: expand support for --tabs arguments
2021-07-31 10:33:08 +02:00
Sylvestre Ledru
638b31a877
Merge pull request #2520 from miDeb/sort/fixes
sort: fix some exit codes and error messages
2021-07-31 10:11:12 +02:00
Sylvestre Ledru
8620220298
Merge pull request #2511 from dezgeg/stat-t
stat: Support \t in --printf format
2021-07-31 09:52:42 +02:00
Sylvestre Ledru
fd02ef2dc1
Merge pull request #2516 from jfinkels/tac-read-dir-error-message
tac: correct error message when reading from directory
2021-07-31 09:49:54 +02:00
Sylvestre Ledru
00f6fce89d
Merge pull request #2518 from jfinkels/tac-no-line-separators-in-file
tac: handle no line separators in file
2021-07-31 09:44:29 +02:00
Sylvestre Ledru
938f79aebc
Merge branch 'master' into sort/fixes 2021-07-31 09:42:35 +02:00
Jeffrey Finkelstein
fb477360b2 expand: expand support for --tabs arguments
Add support for

* space-separated list of tab stops, like `--tabs="2 4 6"`,
* mixed comma- and space-separated lists, like `--tabs="2,4 6"`,
* the slash specifier in the last tab stop, like `--tabs=1,/5`,
* the plus specifier in the last tab stop, like `--tabs=1,+5`.
2021-07-30 23:46:02 -04:00
Michael Debertol
1bb530eebb sort: validate input files at startup 2021-07-30 23:41:18 +02:00
Michael Debertol
a33b6d87b5 sort: open the output file at the beginning
This causes us to print an error message about an invalid output file
right at the start of the invocation, but *after*  verifying other arguments.
2021-07-30 23:40:53 +02:00
Michael Debertol
c6e044927c sort: print check messages to stderr, not stdout 2021-07-30 23:37:35 +02:00
Michael Debertol
891d25cebd sort: fix exit codes and error messages 2021-07-30 23:37:35 +02:00
Michael Debertol
a214ca60bd sort: allow null bytes for -t 2021-07-30 23:30:52 +02:00
Jeffrey Finkelstein
2648f330e4 tac: handle no line separators in file
Change the behavior of `tac` when there are no line separators in the
input. Previously, it was appending an extra line separator; this commit
prevents that from happening. The input is now writted directly to
stdout.
2021-07-25 15:19:29 -04:00
Jeffrey Finkelstein
abf4c69b28 tac: correct error message when reading from dir.
Correct the error message produced by `tac` when trying to read from a
directory. Previously if the path 'a' referred to a directory, then
running `tac a` would produce the error message

    dir: read error: Invalid argument

after this commit it produces

    a: read error: Invalid argument

which matches GNU `tac`.
2021-07-25 13:55:24 -04:00
Daniel Rocco
d8d71cc477 test: handle additional parentheses edge cases
Handle additional edge cases arising from test(1)’s lack of reserved words.
For example, left parenthesis followed by an operator could indicate
either

* string comparison of a literal left parenthesis, e.g. `( = foo`
* parenthesized expression using an operator as a literal, e.g. `( = != foo )`
2021-07-24 23:02:02 -04:00
Tyler
d1907edd65 Adds additional words to exclude list. Improves documentation in dd.rs. 2021-07-24 16:38:08 -07:00
Tyler
076ff32e85 Removes project-specific cspell files. 2021-07-23 14:53:24 -07:00
Tuomas Tynkkynen
46a2491727 stat: Support \t in --printf format 2021-07-23 19:04:18 +03:00
Tyler
885a875552 Addresses build errors
- Adds words to cspell exceptions
- Converts test macros to use Default trait.
- Converts parser to use Default trait.
- Adds Windows-friendly test files for block/unblock when nl is present
  in test/spec file.
2021-07-22 16:04:35 -07:00
Tyler
989849eca7 Ignores linux-only tests on non-linux platforms. 2021-07-21 18:24:31 -07:00
Tyler
95d9f03cff Merge branch 'master' of github.com:backwaterred/coreutils 2021-07-21 17:33:18 -07:00
backwaterred
7c94bbe238
Merge branch 'uutils:master' into master 2021-07-21 17:33:07 -07:00
Tyler
9d9267e08b Addresses code-quality issues from testsdiepraam and miDeb.
- Removes dd from feat_require_unix (keeps it in feat_common_core)
- Changes name of make_linux_iflags parameter from oflags to iflags.
- Removes roughed out SIGINFO impl.
- Renames plen -> target_len.
- Removes internal fn def for build_blocks and replaces with a call to
  chunks from std.
- Renames apply_ct to the more descriptive apply_conversion
- Replaces manual swap steps in perform_swab with call to swap from std.
- Replaces manual solution with chunks where appropriate (in Read, and Write impl).
- Renames xfer -> transfer (in local variable names).
- Improves documentation for dd_filout/dd_stdout issue.
- Removes commented debug_assert statements.
- Modifies ProdUpdate to contain ReadStat and WriteStat rather than
  copying their fields.
- Addresses verbose return in `Output<File>::new(...)`
- Resoves compiler warning when built as release when signal handler fails to
  register.
- Derives _Default_ trait on ReadStat.
- Adds comments for truncated lines in block unblock tests
- Removes `as u8` in block unblock tests.
- Removes unecessary `#[inline]`
- Delegates multiplier string parsing to uucore::parse_size.
- Renames 'unfailed' -> 'succeeded' for clairity.
- Removes #dead_code warnings. No clippy warnings on my local machine.
- Reworks signal handler to better accomodate platform-specific signals.
- Removes explicit references to "if" and "of" in dd.rs.
- Removes explicit references to "bs", "ibs", "cbs" and "status" in
  parseargs.rs.
- Removes `#[allow(deadcode)]` for OFlags, and IFlags.
- Removes spellchecker ignore from all dd files.
- Adds tests for 'traditional' and 'modern' CLI.
2021-07-21 17:25:10 -07:00
Syukron Rifail M
37c986b005 test_du: ignore unsupported --time=birth 2021-07-19 06:55:11 +07:00