Commit graph

1357 commits

Author SHA1 Message Date
Sylvestre Ledru
fb5650951e
Merge pull request #2696 from jhscheer/fix_check_coreutil_version
common/util: fix parsing of coreutil version
2021-10-02 09:03:23 +02:00
Jan Scheer
e9371dc57d
common/util: fix parsing of coreutil version
For the CICD on macOS, this fixes:

```
---- common::util::tests::test_check_coreutil_version stdout ----
---- common::util::tests::test_expected_result stdout ----
thread 'common::util::tests::test_expected_result' panicked at
'byte index 4 is out of bounds of `9.0`', tests/common/util.rs:1172:41
```
2021-10-02 00:58:04 +02:00
Sylvestre Ledru
01d098993b
Merge pull request #2662 from Smicry/master
add kill -l final new line #2644
2021-09-29 09:58:50 +02:00
Jan Scheer
30c8a43788
test_chroot: add comments 2021-09-22 13:53:57 +02:00
Jan Scheer
8db8d8ac4e
chroot: add 'test_default_shell` 2021-09-19 22:21:29 +02:00
Sylvestre Ledru
8d418cd61c
Merge pull request #2672 from oeble/kill_with_signal_name
Kill with signal name
2021-09-18 22:55:27 +02:00
Sylvestre Ledru
3e8b4045c8
Merge pull request #2675 from blyxxyz/whoami-cleanup
whoami: Cleanup
2021-09-18 17:20:09 +02:00
Jan Verbeek
7ea2bfbe26 seq: replace loops with a single format string
Replace two loops that print leading and trailing 0s when printing a
number in fixed-width mode with a single call to `write!()` with the
appropriate formatting parameters.
2021-09-18 10:27:03 -04:00
Jeffrey Finkelstein
bfb1327ad4 seq: use print_seq_integers() regardless of last
Ensure that the `print_seq_integers()` function is called when the first
number and the increment are integers, regardless of the type of the
last value specified.
2021-09-18 10:27:03 -04:00
Sylvestre Ledru
7fb1fcfac5
Merge pull request #2686 from jfinkels/hashsum-window-text-mode
hashsum: add tests for Windows text mode
2021-09-18 09:16:48 +02:00
Jeffrey Finkelstein
2ac5dc0a70 seq: compute correct width for scientific notation
Change the way `seq` computes the number of digits needed to print a
number so that it works for inputs given in scientific notation.
Specifically, this commit parses the input string to determine whether
it is an integer, a float in decimal notation, or a float in scientific
notation, and then computes the number of integral digits and the number
of fractional digits based on that. This also supports floating point
negative zero, expressed in both decimal and scientific notation.
2021-09-17 23:49:54 -04:00
Jeffrey Finkelstein
cd5f676903 hashsum: add tests for Windows text mode 2021-09-17 21:24:43 -04:00
Jan Scheer
79d838b1c3
Merge branch 'master' into ls_selinux 2021-09-17 14:14:47 +02:00
Smicry
89428a77f3 fix kill list final new line test 2021-09-14 23:56:08 +08:00
Jan Verbeek
0a3785bf84 whoami: Run tests on Windows 2021-09-14 14:13:58 +02:00
Jeffrey Finkelstein
60025800c3 seq: trim leading whitespace from inputs 2021-09-13 21:46:17 -04:00
Michael Debertol
5d7e7ed4c0
Merge pull request #2651 from jhscheer/ls_small_fix_for_test_from_2627
test_ls: add features for uutils called by ccmd
2021-09-13 18:35:32 +02:00
Michael Debertol
570f23ac90
Merge pull request #2647 from jfinkels/seq-test-inf
seq: use stdout.write_all() instead of print!()
2021-09-13 18:34:24 +02:00
Michael Debertol
5faa4c41db
Merge pull request #2607 from jfinkels/tac-regex
tac: add support for --regex option to tac
2021-09-13 18:12:57 +02:00
Sylvestre Ledru
7712fd02f2
Merge pull request #2670 from sylvestre/freebsd3
Fixed a warning on freebdsd
2021-09-13 18:09:00 +02:00
Jan Scheer
4dc6536bb9
Merge branch 'master' into ls_selinux 2021-09-13 13:42:51 +02:00
Jan Scheer
cd2153eac6
ls: (--context/-Z) add support for invalid utf8
If security context byte slice contains invalid utf8:
* issue warning
* show replacement characters for invalid utf8 sequences
2021-09-13 13:24:44 +02:00
Sylvestre Ledru
450a3faf9f
Add to the spell ignore list 2021-09-13 12:29:28 +02:00
Jan Scheer
deedb73bcb
tests/common: make call to host_name_for idempotent
This fixes an issue on macOS/bsd where multiple calls
to `host_name_for` each added a prefix 'g'.
The issue led to some tests being skipped because `util_name` was
renamed to e.g. "ggid" instead of "gid".
2021-09-13 12:28:47 +02:00
Smicry
db21fef95d fix kill list final new line test 2021-09-13 09:27:14 +08:00
Sylvestre Ledru
cc8522a2db Fixed a warning on freebdsd:
warning: unused import: `std::os::unix::fs::PermissionsExt`
2021-09-12 23:14:34 +02:00
Smicry
7d445612a2 add kill list final new line test 2021-09-13 00:15:53 +08:00
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