Commit graph

5365 commits

Author SHA1 Message Date
Yağız can Değirmenci
8fe34c72d2 test: fix tests 2021-05-26 03:07:49 +03:00
Yağız can Değirmenci
071899d24d tests: delete 'error:' prefix from the tests 2021-05-26 02:45:53 +03:00
Matt Blessed
7240b12895 uucore: implement backup control
Most of these changes were sourced from mv's existing backup control
implementation. A later commit will update the mv utility to use this
new share backup control.
2021-05-25 19:44:09 -04:00
Yağız can Değirmenci
898d2eb489 chore: delete 'error:' prefix on show_error 2021-05-26 02:32:02 +03:00
Yağız can Değirmenci
c78a7937f8 chore: delete show_info macro and replace with show_error 2021-05-26 02:27:10 +03:00
Yağız can Değirmenci
a77e92cc96 chore: delete unused macros 2021-05-26 01:53:40 +03:00
Sylvestre Ledru
cdd74afa3f
Merge pull request #2273 from ycd/mv-perm-error
mv: log proper error message when permission error occurs
2021-05-25 21:44:04 +02:00
Sylvestre Ledru
f0a962868a
Merge pull request #2274 from sylvestre/gnu-ci2
Try to decrease the size of the GNU log
2021-05-25 18:12:23 +02:00
Sylvestre Ledru
97d15e34d9
Disable some factor tests 2021-05-25 14:58:56 +02:00
Sylvestre Ledru
98f09a6b8b gnu/ci: don't run seq-precision - logs are too long 2021-05-24 22:33:53 +02:00
Sylvestre Ledru
962e4198b2 gnu/ci: limit the number of factor runs 2021-05-24 22:33:53 +02:00
Yağız can Değirmenci
e5e7ca8dc5 fix: simplify logic 2021-05-24 21:20:59 +03:00
Yağız can Değirmenci
991fcc548c fix: log error messages properly on permission errors 2021-05-24 21:07:45 +03:00
Terts Diepraam
da085eca98
Merge pull request #2259 from jfinkels/wc-compute-each-file-and-print
wc: print counts for each file as soon as computed
2021-05-24 17:55:10 +02:00
Sylvestre Ledru
9f73a9faf4
Merge pull request #2272 from miDeb/expr-substr
expr: make substr infallible
2021-05-24 00:11:59 +02:00
Michael Debertol
218f523e1b expr: make substr infallible
Instead of returning an Err it should return the "null string"
(in our case that's the empty string) when the offset or length
is invalid.
2021-05-23 22:22:34 +02:00
Sylvestre Ledru
4061ada132
Merge pull request #2267 from jhscheer/who_fix_runlevel
who: exclude `--runlevel` from non Linux targets (fix #2239)
2021-05-23 13:41:56 +02:00
Sylvestre Ledru
3dfc3c64de
Merge pull request #2268 from sylvestre/windows-ci
Workaround the Windows CI install issue.
2021-05-23 13:40:59 +02:00
Sylvestre Ledru
1860e61f83 Workaround the Windows CI install issue.
Fails trom time to time with:
```
info: installing component 'rustc'
memory allocation of 16777216 bytes failed
Error: The process 'C:\Rust\.cargo\bin\rustup.exe' failed with exit code 3221226505
```

on  Build (windows-latest, i686-pc-windows-gnu, feat_os_windows)
2021-05-23 10:35:46 +02:00
Sylvestre Ledru
7bf076505f
Merge branch 'master' into who_fix_runlevel 2021-05-23 09:32:37 +02:00
Sylvestre Ledru
b175534a97
Merge pull request #2264 from miDeb/sort-sort-flag
sort: support --sort flag and check for conflicts
2021-05-23 09:30:03 +02:00
Sylvestre Ledru
41bd025d00
Merge pull request #2209 from jfinkels/head-ring-buffer
head: add abstractions for "all but last n lines"
2021-05-23 09:28:17 +02:00
Sylvestre Ledru
de81014646
Merge pull request #2266 from sylvestre/rustfmt
rustfmt the recent change
2021-05-23 09:26:25 +02:00
Jeffrey Finkelstein
bc9db289e8 head: add abstractions for "all but last n lines"
Add some abstractions to simplify the `rbuf_but_last_n_lines()`
function, which implements the "take all but the last `n` lines"
functionality of the `head` program. This commit adds

- `RingBuffer`, a fixed-size ring buffer,
- `ZLines`, an iterator over zero-terminated "lines",
- `TakeAllBut`, an iterator over all but the last `n` elements of an
  iterator.

These three together make the implementation of
`rbuf_but_last_n_lines()` concise.
2021-05-22 23:56:48 -04:00
Jeffrey Finkelstein
1f1cd3d966 truncate: re-organize into one func for each mode
Reorganize the code in `truncate.rs` into three distinct functions
representing the three modes of operation of the `truncate` program. The
three modes are

- `truncate -r RFILE FILE`, which sets the length of `FILE` to match the
  length of `RFILE`,
- `truncate -r RFILE -s NUM FILE`, which sets the length of `FILE`
  relative to the given `RFILE`,
- `truncate -s NUM FILE`, which sets the length of `FILE` either
  absolutely or relative to its curent length.

This organization of the code makes it more concise and easier to
follow.
2021-05-22 23:54:39 -04:00
Jeffrey Finkelstein
c6d4d0c07d truncate: create TruncateMode::to_size() method
Create a method that computes the final target size in bytes for the
file to truncate, given the reference file size and the parameter to the
`TruncateMode`.
2021-05-22 23:54:00 -04:00
Jeffrey Finkelstein
544ae87575 truncate: add parse_mode_and_size() helper func
Add a helper function to contain the code for parsing the size and the
modifier symbol, if any. This commit also changes the `TruncateMode`
enum so that the parameter for each "mode" is stored along with the
enumeration value. This is because the parameter has a different meaning
in each mode.
2021-05-22 23:53:59 -04:00
Jeffrey Finkelstein
5eb2a5c3e1 truncate: remove read permissions from OpenOptions
Remove "read" permissions from the `OpenOptions` when opening a new file
just to truncate it. We will never read from the file, only write to
it. (Specifically, we will only call `File::set_len()`.)
2021-05-22 23:45:05 -04:00
Jeffrey Finkelstein
a746e37dc7 truncate: add test for -r and -s options together
Add a test for when the reference file is not found and both `-r` and
`-s` options are given on the command-line.
2021-05-22 23:45:05 -04:00
Jan Scheer
44c033a013 who: exclude --runlevel from non Linux targets (fix #2239) 2021-05-23 03:05:15 +02:00
Sylvestre Ledru
95092e6440 ignore test_should_calculate_implicit_padding_per_free_argument
Fails from time to time with
```
---- test_numfmt::test_should_calculate_implicit_padding_per_free_argument stdout ----
current_directory_resolved:
run: /target/x86_64-unknown-linux-musl/debug/coreutils numfmt --from=auto    1Ki         2K
thread 'test_numfmt::test_should_calculate_implicit_padding_per_free_argument' panicked at 'failed to write to stdin of child: Broken pipe (os error 32)', tests/common/util.rs:859:21
```
2021-05-23 00:34:01 +02:00
Sylvestre Ledru
4aaeede3d8 rustfmt the recent change 2021-05-23 00:13:53 +02:00
Sylvestre Ledru
70e65c419f
Merge pull request #2263 from sylvestre/json-hash
gnu/ci: also store the hash in the json
2021-05-22 23:36:02 +02:00
Michael Debertol
c1f67ed775 sort: support --sort flag and check for conflicts
`sort` supports three ways to specify the sort mode: a long option
(e.g. --numeric-sort), a short option (e.g. -n) and the sort flag
(e.g. --sort=numeric).
This adds support for the sort flag.

Additionally, sort modes now conflict, which means that an error is
shown when multiple modes are passed, instead of silently picking a mode.
For consistency, I added the `random` sort mode to the `SortMode` enum,
instead of it being a bool flag.
2021-05-22 23:10:41 +02:00
Sylvestre Ledru
9f0ef3ba54 gnu/ci: also store the hash in the json 2021-05-22 21:59:54 +02:00
Sylvestre Ledru
726f271273
Merge pull request #2239 from devnexen/fbsd_who_build_fix
who freebsd build fix unsupported RUN_LVL option only for other platf…
2021-05-22 21:34:09 +02:00
Jeffrey Finkelstein
4521aa2659 wc: print counts for each file as soon as computed
Change the behavior of `wc` to print the counts for a file as soon as
it is computed, instead of waiting to compute the counts for all files
before writing any output to `stdout`. The new behavior matches the
behavior of GNU `wc`.

The old behavior looked like this (the word "hello" is entered on
`stdin`):

    $ wc emptyfile.txt -
    hello
	  0       0       0 emptyfile.txt
	  1       1       6
	  1       1       6 total

The new behavior looks like this:

    $ wc emptyfile.txt -
	  0       0       0 emptyfile.txt
    hello
	  1       1       6
	  1       1       6 total
2021-05-22 14:27:37 -04:00
Sylvestre Ledru
73fb426b2b
Merge pull request #2252 from jfinkels/realpath-simplify
realpath: use uucore::fs::canonicalize() to reduce code duplication
2021-05-22 19:10:59 +02:00
David Carlier
fcb079e20e who freebsd build fix unsupported RUN_LVL option only for other platforms. 2021-05-22 18:07:02 +01:00
Sylvestre Ledru
542deb8888
Merge pull request #2246 from miDeb/sort-automatic-extsort
sort: automatically fall back to extsort
2021-05-22 17:21:02 +02:00
Sylvestre Ledru
8055f26a73
Merge pull request #2228 from jfinkels/tail-obo-positive-bytes
tail: fix off-by-one issue for +NUM args
2021-05-22 17:18:55 +02:00
Jeffrey Finkelstein
4b5c3efe85 realpath: use uucore::fs::canonicalize()
Use the `uucore::fs::canonicalize()` function to simplify the
implementation of `realpath`.
2021-05-22 11:18:16 -04:00
Jeffrey Finkelstein
bee3b1237c uucore::fs: don't canonicalize last component
Change the behavior of `uucore::fs::canonicalize()` when `can_mode` is
`CanonicalizeMode::None` so that it does not attempt to resolve the
final component if it is a symbolic link. This matches the behavior of
the function for the non-final components of a path when `can_mode` is
`None`.
2021-05-22 11:18:16 -04:00
Sylvestre Ledru
66cfdb8644
Merge pull request #2143 from nbraud/factor/faster/table
factor::table: Implement a batched version w/ improved performance
2021-05-22 17:18:07 +02:00
Sylvestre Ledru
66dd6dbeff
Merge pull request #2244 from jfinkels/truncate-fix-round-up-character
truncate: fix character used to indicate round up
2021-05-22 14:03:59 +02:00
Michael Debertol
088443276a sort: improve handling of buffer size cmd arg
Instead of overflowing when calculating the buffer size, use
saturating_{pow, mul}.

When failing to parse the buffer size, we now crash instead of silently
ignoring the error.
2021-05-22 14:00:07 +02:00
Sylvestre Ledru
9b9397065f
Merge pull request #2250 from sylvestre/cargo-update
refresh cargo.lock with recent updates
2021-05-22 12:42:04 +02:00
Sylvestre Ledru
4d3be19de3
Merge pull request #2240 from jhscheer/macos_test_coreutils
who/stat/pinky: adjust tests to be compatible with running on macOS
2021-05-22 12:39:05 +02:00
Sylvestre Ledru
424a99f0e6
Merge pull request #2193 from jfinkels/2186-min-width-stdin
wc: compute minimum width to format counts up front
2021-05-22 12:37:42 +02:00
Sylvestre Ledru
c83eaf195a
Merge pull request #2245 from siebenHeaven/fix_ls_path_printing
Fix ls path printing
2021-05-22 12:36:46 +02:00