Commit graph

1678 commits

Author SHA1 Message Date
Niyaz Nigmatullin
161fc6b642 test/dd: add ignore_stdin_write_error, because count=0 and dd doesn't
read anything
2022-08-08 22:44:59 +03:00
Niyaz Nigmatullin
04df57ebd4 test/tail: ignore pipe errors when tail -n 0, since it doesn't read
anything
2022-08-08 22:29:53 +03:00
Niyaz Nigmatullin
fee851dc1c
test/cp: fix test_copy_through_dangling_symlink_no_dereference_permissions (#3789)
* test/cp: -p changes ctime and added sleep for better timestamp testing

* test/cp: add nanoseconds checking for copied timestamps

* test/cp: made compilable on other OSes

* test/cp: added error messages to assert_eq calls
2022-08-08 11:11:17 +02:00
Jan Scheer
0555745052
tests: fix Freebsd test failures 2022-08-05 08:04:25 +02:00
Pierre Marsais
e1991525af
cp: Implement --sparse flag (#3766)
* cp: Refactor `reflink`/`sparse` handling to enable `--sparse` flag

`--sparse` and `--reflink` options have a lot of similarities:
 - They have similar options (`always`, `never`, `auto`)
 - Both need OS specific handling
 - They can be mutually exclusive

Prior to this change, `sparse` was defined as `CopyMode`, but `reflink`
wasn't. Given the similarities, it makes sense to handle them similarly.

The idea behind this change is to move all OS specific file copy
handling in the `copy_on_write_*` functions. Those function then
dispatch to the correct logic depending on the arguments (at the moment,
the tuple `(reflink, sparse)`).

Also, move the handling of `--reflink=never` from `copy_file` to the
`copy_on_write_*` functions, at the cost of a bit of code duplication,
to allow `copy_on_write_*` to handle all cases (and later handle
`--reflink=never` with `--sparse`).

* cp: Implement `--sparse` flag

This begins to address #3362

At the moment, only the `--sparse=always` logic matches the requirement
form GNU cp info page, i.e. always make holes in destination when
possible.

Sparse copy is done by copying the source to the destination block by
block (blocks being of the destination's fs block size). If the block
only holds NUL bytes, we don't write to the destination.

About `--sparse=auto`: according to GNU cp info page, the destination
file will be made sparse if the source file is sparse as well. The next
step are likely to use `lseek` with `SEEK_HOLE` detect if the source
file has holes. Currently, this has the same behaviour as
`--sparse=never`. This `SEEK_HOLE` logic can also be applied to
`--sparse=always` to improve performance when copying sparse files.

About `--sparse=never`: from my understanding, it is not guaranteed that
Rust's `fs::copy` will always produce a file with no holes, as
["platform-specific behavior may change in the
future"](https://doc.rust-lang.org/std/fs/fn.copy.html#platform-specific-behavior)

About other platforms:
 - `macos`: The solution may be to use `fcntl` command `F_PUNCHHOLE`.
 - `windows`: I only see `FSCTL_SET_SPARSE`.

This should pass the following GNU tests:
 - `tests/cp/sparse.sh`
 - `tests/cp/sparse-2.sh`
 - `tests/cp/sparse-extents.sh`
 - `tests/cp/sparse-extents-2.sh`

`sparse-perf.sh` needs `--sparse=auto`, and in particular a way to skip
holes in the source file.

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2022-08-04 13:22:59 +02:00
Pierre Marsais
90a9829287
cp: truncate destination when --reflink is set (#3759)
* cp: truncate destination when `--reflink` is set

This is needed in order to allow overriding an existing file.

```
$ truncate -s 512M /tmp/disk.img
$ mkfs.btrfs /tmp/disk.img
[...]
$ mkdir /tmp/disk
$ sudo mount /tmp/disk.img /tmp/disk
$ sudo chown $(id -u):$(id -g) -R /tmp/disk
$ for i in $(seq 0 8192); do echo -ne 'a' >>/tmp/disk/src1; done
$ echo "success" >/tmp/disk/src2
$
$ # GNU ls supports overriding files created with `--reflink`
$ cp --reflink=always /tmp/disk/src1 /tmp/disk/dst1
$ cp --reflink=always /tmp/disk/src2 /tmp/disk/dst1
$ cat /tmp/disk/dst1
success
$
$ # Now testing with uutils
$ cargo run cp --reflink=always /tmp/disk/src1 /tmp/disk/dst2
    Finished dev [unoptimized + debuginfo] target(s) in 0.25s
     Running `target/debug/coreutils cp --reflink=always /tmp/disk/src1 /tmp/disk/dst2`
$ cargo run cp --reflink=always /tmp/disk/src2 /tmp/disk/dst2
    Finished dev [unoptimized + debuginfo] target(s) in 0.26s
     Running `target/debug/coreutils cp --reflink=always /tmp/disk/src2 /tmp/disk/dst2`
cp: failed to clone "/tmp/disk/src2" from "/tmp/disk/dst2": Invalid argument (os error 22)
$ cat /tmp/disk/dst2
[lots of 'a']
$
$ # With truncate(true)
$ cargo run cp --reflink=always /tmp/disk/src1 /tmp/disk/dst3
    Finished dev [unoptimized + debuginfo] target(s) in 7.98s
     Running `target/debug/coreutils cp --reflink=always /tmp/disk/src1 /tmp/disk/dst3`
$ cargo run cp --reflink=always /tmp/disk/src2 /tmp/disk/dst3
    Finished dev [unoptimized + debuginfo] target(s) in 0.27s
     Running `target/debug/coreutils cp --reflink=always /tmp/disk/src2 /tmp/disk/dst3`
$ cat /tmp/disk/dst3
success
```
2022-08-04 08:50:19 +02:00
Sylvestre Ledru
c660fc700f
Merge pull request #3757 from cakebaker/clap_update
bump clap from 3.1.18 to 3.2.15
2022-08-02 09:56:01 +02:00
Sylvestre Ledru
9b81e09f7a
Merge pull request #3764 from cakebaker/numfmt_preserve_trailing_zeros
numfmt: preserve trailing zeros
2022-08-01 13:32:55 +02:00
Daniel Hofstetter
e642ca90dd numfmt: preserve trailing zeros 2022-08-01 09:48:13 +02:00
Pierre Marsais
4ad0d5c5a3
ls: Implement --zero flag. (#2929) (#3746)
* ls: Implement --zero flag. (#2929)

This flag can be used to provide a easy machine parseable output from
ls, as discussed in the GNU bug report
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49716.

There are some peculiarities with this flag:

 - Current implementation of GNU ls of the `--zero` flag implies some
   other flags. Those can be overridden by setting those flags after
   `--zero` in the command line.
 - This flag is not compatible with `--dired`. This patch is not 100%
   compliant with GNU ls: GNU ls `--zero` will fail if `--dired` and
   `-l` are set, while with this patch only `--dired` is needed for the
   command to fail.

We also add `--dired` flag to the parser, with no additional behaviour
change.

Testing done:
```
$ bash util/build-gnu.sh
 [...]
$ bash util/run-gnu-test.sh tests/ls/zero-option.sh
 [...]
 PASS: tests/ls/zero-option.sh
 ============================================================================
 Testsuite summary for GNU coreutils 9.1.36-8ec11
 ============================================================================
 # TOTAL: 1
 # PASS:  1
 # SKIP:  0
 # XFAIL: 0
 # FAIL:  0
 # XPASS: 0
 # ERROR: 0
 ============================================================================
```

* Use the US way to spell Behavior

* Fix formatting with cargo fmt -- tests/by-util/test_ls.rs

* Simplify --zero flag overriding logic by using index_of

Also, allow multiple --zero flags, as this is possible with GNU ls
command. Only the last one is taken into account.

Co-authored-by: Sylvestre Ledru <sledru@mozilla.com>
2022-07-31 19:02:50 +02:00
Daniel Hofstetter
fc4544c42b bump clap from 3.1.18 to 3.2.15 2022-07-29 14:05:02 +02:00
Daniel Hofstetter
ee13bc41e7 numfmt: implement --format 2022-07-28 09:59:30 +02:00
Sam Nystrom
4e72e284b5
ls: silently ignore -T option (#3718)
* ls: silently ignore `-T` option
2022-07-26 10:35:43 +02:00
Sylvestre Ledru
2fa4d6a2bb
Merge pull request #3740 from resistor/main
Implement wc fast paths that skip Unicode decoding.
2022-07-25 21:15:13 +02:00
Owen Anderson
0e7f1c4c0d Add missing testcases for wc. 2022-07-24 21:56:07 -07:00
Daniel Hofstetter
34b4853890 numfmt: don't round floats if --from is "none" 2022-07-24 16:25:52 +02:00
Sylvestre Ledru
62305e67d1
Merge pull request #3719 from andrewbaptist/main
split: Don't overwrite files
2022-07-23 22:54:57 +02:00
Niyaz Nigmatullin
5f3f1112d1
Basename arguments simple format (#3736)
* basename: support simple format

* tests/basename: add tests for simple format

* basename: follow clippy advice
2022-07-22 13:28:54 +02:00
Andrew Baptist
f2cfc15a70 split: Don't overwrite files
Check that a file exists by calling create_new and changing the
interface of instantiate_current_writer to return a Result rather
than calling unwrap.
2022-07-21 12:06:13 -04:00
Daniel Hofstetter
29c4d08ee9 numfmt: enable ignored test 2022-07-21 13:20:42 +02:00
Sylvestre Ledru
ba24565b60
Merge pull request #3732 from cakebaker/numfmt_auto_suf_si_i
numfmt: show "invalid suffix" error for "i" suffix
2022-07-20 22:51:14 +02:00
Daniel Hofstetter
74bd9a26d6 numfmt: show "invalid suffix" error for "i" suffix 2022-07-20 17:51:36 +02:00
Niyaz Nigmatullin
406d3931e9 tests/ln: fix tests according to new messages 2022-07-19 17:34:52 +03:00
Owen Anderson
735db78b3d
wc: specialize scanning loop on settings. (#3708)
* wc: specialize scanning loop on settings.

The primary computational loop in wc (iterating over all the
characters and computing word lengths, etc) is configured by a
number of boolean options that control the text-scanning behavior.
If we monomorphize the code loop for each possible combination of
scanning configurations, the rustc is able to generate better code
for each instantiation, at the least by removing the conditional
checks on each iteration, and possibly by allowing things like
vectorization.

On my computer (aarch64/macos), I am seeing at least a 5% performance
improvement in release builds on all wc flag configurations
(other than those that were already specialized) against
odyssey1024.txt, with wc -l showing the greatest improvement at 15%.

* Reduce the size of the wc dispatch table by half.

By extracting the handling of hand-written fast-paths to the
same dispatch as the automatic specializations, we can avoid
needing to pass `show_bytes` as a const generic to
`word_count_from_reader_specialized`. Eliminating this parameter
halves the number of arms in the dispatch.
2022-07-18 12:16:52 +02:00
Sylvestre Ledru
189a8af450
Merge pull request #3721 from niyaznigmatullin/add_test_for_issue_3332
tests/cp: add test for cp-parents.sh
2022-07-18 12:11:30 +02:00
Niyaz Nigmatullin
0ab0f2761f tests/ln: add test for same file 2022-07-18 08:17:37 +03:00
Niyaz Nigmatullin
028c08cce2 tests/rm: add test for issue #3722 2022-07-17 23:34:04 +03:00
Niyaz Nigmatullin
147f83f68a tests/cp: add test for cp-parents.sh 2022-07-17 23:04:09 +03:00
Niyaz Nigmatullin
0ea3a735ca
readlink: symlink loop handling (#3717)
readlink: fix symlink loop handling
2022-07-14 22:32:55 +02:00
Sylvestre Ledru
882cd527ff
Merge pull request #3704 from Sciencentistguy/once_cell
Replace lazy_static with once_cell
2022-07-13 16:15:47 +02:00
Daniel Hofstetter
9e44acf307 numfmt: reject suffix if unit is "none" 2022-07-13 10:47:59 +02:00
Jamie Quigley
1a270361c0
Replace lazy_static with once_cell 2022-07-12 14:08:30 +01:00
Daniel Hofstetter
aef24db90f numfmt: show error if "i" suffix is missing 2022-07-12 10:58:07 +02:00
Niyaz Nigmatullin
de65d4d649
Realpath relative options (#3710)
* realpath: introduce relative options, make correct exit codes, make pass
GNU test mist/realpath.sh
2022-07-12 08:29:20 +02:00
Sylvestre Ledru
e239ed9417
Merge pull request #3692 from jfinkels/cp-preserve-perm-link
cp: correctly copy attributes of a dangling symbolic link
2022-07-11 22:50:24 +02:00
Sylvestre Ledru
8074020a8b
Merge pull request #3705 from cakebaker/numfmt_unit
numfmt: implement "--to-unit" & "--from-unit"
2022-07-11 22:46:56 +02:00
Niyaz Nigmatullin
da5808d4ac
ls: add already listed message (#3707)
* ls: handle looping symlinks infinite printing

* ls: better coloring and printing symlinks when dereferenced

* tests/ls: add dereferencing and symlink loop tests

* ls: reformat changed using rustfmt

* ls: follow clippy advice for cleaner code

* uucore/fs: fix FileInformation to open directory handles in Windows as
well
2022-07-11 17:18:58 +02:00
Niyaz Nigmatullin
9d285e953d
Realpath symlinks handling, solves issue #3669 (#3703) 2022-07-10 16:49:25 +02:00
Daniel Hofstetter
1f292dd834 numfmt: implement "--to-unit" & "--from-unit" 2022-07-09 08:01:27 +02:00
Sylvestre Ledru
392ae87a9f
Merge pull request #3700 from cakebaker/comm_enable_output_delimiter_test
comm: enable "output_delimiter" test
2022-07-08 18:41:51 +02:00
Ed Smith
5c13e88f8b Do not trap pipe errors in yes
This is part of fixing the tee tests. 'yes' is used by the GNU test
suite to identify what the SIGPIPE exit code is on the target
platform. By trapping SIGPIPE, it creates a requirement that other
utilities also trap SIGPIPE (and exit 0 after SIGPIPE). This is
sometimes at odds with their desired behaviour.
2022-07-07 15:23:50 +02:00
Ed Smith
a360504574 Implement tee -p and --output-error
This has the following behaviours. On Unix:

- The default is to exit on pipe errors, and warn on other errors.

- "--output-error=warn" means to warn on all errors

- "--output-error", "--output-error=warn-nopipe" and "-p" all mean
  that pipe errors are suppressed, all other errors warn.

- "--output-error=exit" means to warn and exit on all errors.

- "--output-error=exit-nopipe" means to suppress pipe errors, and to
  warn and exit on all other errors.

On non-Unix platforms, all pipe behaviours are ignored, so the default
is effectively "--output-error=warn" and "warn-nopipe" is identical.
The only meaningful option is "--output-error=exit" which is identical
to "--output-error=exit-nopipe" on these platforms.

Note that warnings give a non-zero exit code, but do not halt writing
to non-erroring targets.
2022-07-07 15:23:50 +02:00
Sylvestre Ledru
922afa29ff
Merge branch 'main' into cp-preserve-perm-link 2022-07-07 15:22:57 +02:00
Daniel Hofstetter
249b398906 comm: enable "output_delimiter" test 2022-07-07 15:22:43 +02:00
Daniel Hofstetter
ac35a1b985 comm: use NUL if delimiter is empty 2022-07-06 13:50:23 +02:00
Sylvestre Ledru
43a5b8c7d7
Merge pull request #3671 from niyaznigmatullin/fix_realpath_test
test_realpath: fixed test to be the one that was supposed to be
2022-07-06 09:42:15 +02:00
Jeffrey Finkelstein
4780690caa cp: copy attributes of dangling symbolic link
Fix a bug in which `cp` incorrectly exited with an error when
attempting to copy the attributes of a dangling symbolic link (that
is, when running `cp -P -p`).

Fixes #3531.
2022-07-03 15:17:00 -04:00
Gergely Kalas
bd96f25ec8 Add new test to verify GNU compatible quotation.
Co-authored-by: anastygnome <noreplygitemail@protonmail.com>
2022-07-01 16:43:09 +02:00
Daniel Hofstetter
220c3ca4fb numfmt: show error if --padding is zero 2022-07-01 13:34:05 +02:00
Sylvestre Ledru
f6a88552ab
Merge pull request #3667 from cakebaker/set_default_missing_value
uniq: set default missing value for "group" and "all-repeated" args
2022-07-01 00:01:21 +02:00
Daniel Hofstetter
72862512da uniq: set default missing value for args 2022-06-30 11:52:46 +02:00
Niyaz Nigmatullin
4e936d2d0d test_realpath: include issue id to ignored testcase 2022-06-30 11:52:17 +02:00
Niyaz Nigmatullin
9b2fa39760 test_realpath: get back to contains to pass in MacOs 2022-06-30 11:52:17 +02:00
Niyaz Nigmatullin
b3642b64c5 test_realpath: reformatted using rustfmt 2022-06-30 11:52:17 +02:00
Niyaz Nigmatullin
1ecc789dea test_realpath: fixed test to be the one that was supposed to be and
added non-passing test
2022-06-30 11:52:17 +02:00
Daniel Hofstetter
113f0bd92b realpath: add "--no-symlinks" alias 2022-06-30 11:51:24 +02:00
Sylvestre Ledru
b6bb476aa0
Merge pull request #3659 from cakebaker/ticket_3637
paste: implement "-z" flag
2022-06-23 22:20:09 +02:00
Sylvestre Ledru
2fb743b72a
Merge pull request #3663 from niyaznigmatullin/fix_install_C_test
Fix install c test
2022-06-23 17:09:02 +02:00
Sylvestre Ledru
7c7c694837
Merge pull request #3657 from ElijahSink/main
closes #3650: install -V does not show the filename
2022-06-23 16:57:35 +02:00
Niyaz Nigmatullin
ba136ba3fb tests: add tests for install to check -C option usage 2022-06-22 21:30:59 +03:00
Daniel Hofstetter
cf605c24d0 unexpand: handle too large "tabs" arguments 2022-06-22 09:30:11 +02:00
Daniel Hofstetter
d0f608c69f paste: implement "-z" flag
Fixes #3637
2022-06-22 09:30:00 +02:00
ElijahSink
f62909c1ff
Merge branch 'uutils:main' into main 2022-06-22 00:45:41 -04:00
Jan Scheer
75edeea5e4
tail: reduce CPU load for polling (#3618)
* tail: reduce CPU load for polling

This reduces the CPU load for polling drastically (from ~80% down to ~5%)
by removing/fixing several previous workarounds related to polling,
while still passing all related GNU test-suite checks.
* set Notify::PollWatcher delay to: sleep_sec/10 instead of
  sleep_sec/100
* set recv_timeout to sleep_sec instead of sleep_sec/100
* remove the manual polling of watched files

Bugs:
* fix an issue with headers to consistently pass
"test_follow_name_retry_headers" and "gnu/tests/tail-2/overlay-headers.sh"

Code clean-up and refactor
* make fields of struct FileHandling private (and add getters/setters)
to ensure that the paths are absolute and match the paths returned by
Notify::Events
* replace calls to "crash!" with "return USimpleError"
* clean-up formatting
2022-06-21 22:21:19 +02:00
Elijah Sink
81c45cde47 tests/install: fix mistakes when adding previous 2022-06-20 17:31:10 -05:00
Elijah Sink
2965581847 tests/install: add failing test for #3650 2022-06-20 14:26:46 -05:00
Sylvestre Ledru
c277e933c9
Merge pull request #3647 from philgebhardt/backup-protect-source
cp: make `--b=simple` protective of source
2022-06-20 17:27:11 +02:00
Phil Gebhardt
30f03b3ded
use existing fixture file instead of new ones 2022-06-18 09:51:39 -07:00
Phil Gebhardt
c49d8e6113
cp: make --b=simple protective of source
When `--backup` is supplied, `cp` will take a backup of *destination* before *source* is copied. When `--backup=simple` is supplied, it is possible for the backup path for *destination* to equal the path for *source*, destroying source before the copy is made. This change prevents this by returning an error instead.

This fixes https://github.com/uutils/coreutils/issues/3629
2022-06-18 03:56:46 -07:00
Daniel Hofstetter
edf4fee48f unexpand: implement "tabs" shortcuts 2022-06-17 14:31:40 +02:00
Sylvestre Ledru
9cfb92df3f
Merge pull request #3612 from cakebaker/ticket_3575
expand: add support for "--tabs" shortcuts
2022-06-16 13:18:38 +02:00
Daniel Hofstetter
46b4b94c42 dircolors: escape "'" and ":" 2022-06-15 15:22:14 +02:00
anastygnome
0ef6732632
Add a test like the one in the issue.
Signed-off-by: anastygnome <noreplygitemail@protonmail.com>
2022-06-13 11:29:13 +02:00
Sylvestre Ledru
b242e6592c
Merge pull request #3617 from jfinkels/dd-float-format-stats-2
dd: only print concise byte counts if count is sufficiently large
2022-06-14 08:01:28 +02:00
Sylvestre Ledru
76d6a4a889
Merge pull request #3613 from Ganneff/lswidthoctal
Forbid octal numbers for width parameter
2022-06-13 16:00:36 +02:00
Joerg Jaspert
fd1e0e6dd7 Correctly parse numbers starting with 0 as octal 2022-06-12 12:55:33 +02:00
Jeffrey Finkelstein
a375644c50 dd: only print concise byte counts if large enough
Update `dd` to only print a concise form of the number of bytes with
an SI prefix (like "1 MB" or "2 GB") if the number is at least
1000. Similarly, only print the concise form with an IEC prefix (like
"1 MiB" or "2 GiB") if the number is at least 1024. For example,

    $ head -c 999 /dev/zero | dd > /dev/null
    1+1 records in
    1+1 records out
    999 bytes copied, 0.0 s, 999.0 KB/s

    $ head -c 1000 /dev/zero | dd > /dev/null
    1+1 records in
    1+1 records out
    1000 bytes (1000 B) copied, 0.0 s, 1000.0 KB/s

    $ head -c 1024 /dev/zero | dd > /dev/null
    2+0 records in
    2+0 records out
    1024 bytes (1 KB, 1024 B) copied, 0.0 s, 1.0 MB/s
2022-06-11 23:16:16 -04:00
Joerg Jaspert
c513692bae Test for (against) octal-looking width 2022-06-11 22:43:46 +02:00
Sylvestre Ledru
98cf16586e
Merge pull request #3603 from cakebaker/return_result_instead_of_crash
unexpand: return Result instead of calling crash!
2022-06-11 19:55:20 +02:00
Sylvestre Ledru
3461b6c452
Merge pull request #3607 from jhscheer/cut_fix_delimiter
cut: fix argument parsing for the delimiter
2022-06-11 19:54:48 +02:00
Daniel Hofstetter
e3cac647f6 expand: add support for "--tabs" shortcuts
Fixes #3575
2022-06-10 13:55:27 +02:00
Daniel Hofstetter
0c0e4dbda4 unexpand: return Result instead of calling crash! 2022-06-10 10:06:28 +02:00
Sylvestre Ledru
d1f7f51f99
Merge pull request #3606 from jhscheer/tail_notify
test_tail: increase delay for test_follow_name_move_create2
2022-06-10 10:05:45 +02:00
Jan Scheer
435984713a
test_tail: increase delay for test_follow_name_move_create2
Increase delay for this test to be more resillient against
load-jitter on the CI test VMs.
2022-06-09 23:44:37 +02:00
Jan Scheer
fa64407cb0
cut: fix argument parsing for the delimiter
This fixes the argument parsing for the delimiter for the two special
cases `-d=` and `-d ''`.
2022-06-09 22:14:43 +02:00
Junji Wei
1ba0bfc67a mktemp: respect POSIXLY_CORRECT env var when parsing args
Signed-off-by: Junji Wei <harukawei99@gmail.com>
2022-06-09 20:51:51 +08:00
Sylvestre Ledru
d7b7b7f8c1
Merge pull request #3595 from cakebaker/specifier_only_allowed_with_last_value
expand: allow specifier only with last value
2022-06-07 15:06:40 +02:00
Sylvestre Ledru
0532c743f1
Merge pull request #2695 from jhscheer/tail_notify
`tail` overhaul (--follow=name, etc.)
2022-06-07 12:05:16 +02:00
Jeffrey Finkelstein
6da070cdd3 mktemp: error on empty --suffix in some situations
Make `mktemp` exit with an error if the `--suffix` option is the empty
string and the template argument does not end in an "X". Previously,
the program succeeded.

Before this commit,

    $ mktemp --suffix= aXXXb
    apBEb

After this commit,

    $ mktemp --suffix= aXXXb
    mktemp: with --suffix, template 'aXXXb' must end in X
2022-06-06 21:24:59 -04:00
Jan Scheer
e8834597f3
Merge branch 'main' into tail_notify 2022-06-06 16:00:46 +02:00
Jan Scheer
beb2b7cf5e
tail: use functionality from uucore::error where applicable
* minor code clean-up
* remove test-suite summary from README
2022-06-06 14:36:51 +02:00
Daniel Hofstetter
804240164b expand: allow specifier only with last value 2022-06-06 14:15:33 +02:00
Sylvestre Ledru
fc5aedfbb7
Merge pull request #3594 from cakebaker/handle_too_large_tab_stop
expand: handle too large tab size
2022-06-06 13:39:19 +02:00
Sylvestre Ledru
3f203c7ab1
Merge pull request #3586 from jfinkels/mktemp-multiple-x-sequences
mktemp: only replace last contiguous block of Xs
2022-06-06 10:06:44 +02:00
Sylvestre Ledru
63347abd19
Merge pull request #3592 from anastygnome/fork
Implement the --sync flag for df. (fixes #3564)
2022-06-06 10:05:51 +02:00
Sylvestre Ledru
c4c6d42f02
Merge pull request #3591 from jhscheer/fix_3589
dircolors: add support for stdin "-" (fix: #3589)
2022-06-06 10:04:42 +02:00
Jan Scheer
18bfc03008
test_dircolors: add test_extra_operand 2022-06-06 00:22:21 +02:00
Daniel Hofstetter
c14ff14e99 expand: handle too large tab size 2022-06-05 13:49:11 +02:00
anastygnome
f5ae859c38 Adds a test for sync.
It is probably too hard to verify that the sync is actually performed,
so we just check that we have a test using the code path, pro forma.

Signed-off-by: anastygnome <noreplygitemail@protonmail.com>
2022-06-05 09:43:59 +02:00
Sylvestre Ledru
69c2871336
Merge pull request #3568 from jfinkels/mktemp-tmpdir-subdirectory
mktemp: combine `--tmpdir` and subdirectory info
2022-06-05 09:33:47 +02:00
Sylvestre Ledru
e2782e2f75
Merge pull request #3583 from cakebaker/ticket_3574
expand: show error if --tabs arg has invalid chars
2022-06-05 09:31:21 +02:00
Jan Scheer
e0efd6cc90
tail: update readme
* add clippy fixes
* add cicd fixes
2022-06-03 13:35:58 +02:00
Daniel Hofstetter
9651cff6c0 expand: show error if --tabs arg has invalid chars
Fixes #3574
2022-06-03 10:36:42 +02:00
Jan Scheer
f1b38e94cd
dircolors: add support for stdin "-" (fix: #3589) 2022-06-03 02:08:09 +02:00
Terts Diepraam
626ed43e05 ls: fix double quoting when color is enabled
When color was enabled the escape_name function was called twice which led to names like `hello world` being displayed as `"'hello world'".
2022-06-03 00:29:56 +02:00
Jan Scheer
94fe42634b
test_tail: a lot of minor improvements
* fix test_retry7
* fix test_follow_descriptor_vs_rename2
* set permissions with set_permissions instead of a call to chmod
* improve documentation
2022-06-02 17:03:49 +02:00
Jan Scheer
2e918813c1
test_tail: add test_follow_name_move_create2 2022-06-02 17:01:22 +02:00
Jan Scheer
42fa386d89
test_tail: add test_follow_truncate_fast 2022-06-02 16:56:09 +02:00
Jan Scheer
f3aacac9d8
test_tail: add test_follow_name_truncate4 2022-06-02 16:55:04 +02:00
Jan Scheer
8ee806a444
Merge branch 'main' into tail_notify 2022-06-02 16:31:25 +02:00
Sylvestre Ledru
68cc9312c8
Merge pull request #3585 from cakebaker/multiple_tabs
expand: allow multiple "tabs" args
2022-06-02 10:08:45 +02:00
Sylvestre Ledru
aeb01c6f52
Merge pull request #3563 from sylvestre/hard-to-sym
ln: Implement -L -P to make tests/ln/hard-to-sym.sh work
2022-06-02 08:19:17 +02:00
Jeffrey Finkelstein
a9e008f230 mktemp: add test for combining --tmpdir, subdir
Add a unit test for combining the directory given in `--tmpdir` with
any subdirectory structure appearing in the prefix of the template
string. For example,

    $ mktemp --tmpdir=a b/cXXX
    a/b/cNqJ

This behavior is currently working, but a unit test was missing.
2022-06-01 18:22:17 -04:00
Jeffrey Finkelstein
cff7833bf6 mktemp: only replace last contiguous block of Xs
Fix a bug in which `mktemp` would replace everything in the template
argument from the first 'X' to the last 'X' with random bytes, instead
of just replacing the last contiguous block of 'X's.

Before this commit,

    $ mktemp XXX_XXX
    2meCpfM

After this commit,

    $ mktemp XXX_XXX
    XXX_Rp5

This fixes test cases `suffix2f` and `suffix2d` in
`tests/misc/mktemp.pl` in the GNU coreutils test suite.
2022-06-01 18:21:21 -04:00
Sylvestre Ledru
36e5b60617
Merge pull request #3566 from cakebaker/print_ls_colors
dircolors: implement --print-ls-colors
2022-06-01 23:11:57 +02:00
Sylvestre Ledru
06c2aea1b4 ln: Implement -L -P to make tests/ln/hard-to-sym.sh work 2022-06-01 23:03:50 +02:00
Daniel Hofstetter
864c666467 expand: allow multiple "tabs" args 2022-06-01 16:18:57 +02:00
Sylvestre Ledru
2ed64fc9a1
Merge pull request #3573 from jfinkels/mktemp-simpler-prefix-suffix
mktemp: simplify file path parameter logic
2022-06-01 08:38:31 +01:00
Jeffrey Finkelstein
43e9fb73b1 mktemp: simplify file path parameter logic
Simplify the logic of computing the file path parameters (the
directory, prefix, suffix, and number of random characters) for the
temporary file created by `mktemp`. This commits adds an `Options`
struct as a layer of indirection between the application logic and
`clap`, and a `Params` struct whose associated function is responsible
for determining the file path parameters from the `Options`. This is
an improvement because the previous code had some logic for
determining file path parameters in one place and some in another
place.
2022-05-31 19:35:01 -04:00
Daniel Hofstetter
113c1855fd df: trim size header in tests
Fixes #3580
2022-05-31 10:34:20 +02:00
Sylvestre Ledru
e276e652dc
Merge pull request #3579 from jfinkels/df-total-label-target-column
df: show "total" label in correct column
2022-05-31 07:42:06 +01:00
Jeffrey Finkelstein
d7b528f60b df: show "total" label in correct column
Show the "total" label in the "source" column or in the "target"
column if the "source" column is not visible.

Before this commit,

    $ df --total --output=target .
    Mounted on
    /
    -

After this commit,

    $ df --total --output=target .
    Mounted on
    /
    total
2022-05-30 11:22:07 -04:00
Jeffrey Finkelstein
dfc1c8a2dd mktemp: exit with status 1 on usage errors 2022-05-30 09:30:47 -04:00
Daniel Hofstetter
6d82523a99 dircolors: implement --print-ls-colors 2022-05-30 09:11:27 +02:00
Jan Scheer
4cb6b094f5
Merge branch 'main' into tail_notify 2022-05-27 23:44:24 +02:00
Jan Scheer
bb5dc8bd2f
tail: verify that -[nc]0 without -f, exit without reading
This passes: "gnu/tests/tail-2/tail-n0f.sh"

* add tests for "-[nc]0 wo -f"

* add bubble-up UResult
* rename return_code -> exit_code
2022-05-27 23:36:31 +02:00
Daniel Hofstetter
598fdc4430 dircolors: make -b & -c args overridable 2022-05-27 10:36:49 +02:00
Jan Scheer
4bbf708c81
tail: fix handling of PermissionDenied Error
* add tests for opening unreadable files
2022-05-26 13:00:40 +02:00
Jan Scheer
6bd9a1d537
Merge branch 'main' into tail_notify 2022-05-26 00:33:12 +02:00
Jan Scheer
519ab2d172
test_tail: add two new tests for --follow
* add test_follow_name_move2
* add test_follow_multiple_untailable

* disable some tests which do not run properly on Android and/or macOS
2022-05-25 23:25:08 +02:00
Sylvestre Ledru
172f5c4182
Merge pull request #3504 from cakebaker/read_blocksize_from_env_vars
df: read block size from env vars
2022-05-25 16:41:41 +02:00
Sylvestre Ledru
fa577603c2
Merge pull request #3471 from 353fc443/mktemp-set-dir-mode
mktemp: change directory permission after creation
2022-05-25 14:56:45 +02:00
Daniel Hofstetter
74a5938acf dircolors: test for correct error for -bp and -cp 2022-05-24 15:32:01 +02:00
Daniel Hofstetter
ea284ce55e df: read block size from env vars 2022-05-23 09:24:07 +02:00
Sylvestre Ledru
c818ca0039
Merge pull request #3551 from jfinkels/mktemp-too-few-xs-suffix
mktemp: include suffix in error message
2022-05-23 08:38:15 +02:00
Jan Scheer
dc4b6f2cf9
Merge branch 'main' into tail_notify 2022-05-23 01:10:32 +02:00
Jan Scheer
6a7b6ccdbe
tail: add test_follow_name_move_retry
* add fixes to pass test_follow_name_move_retry
* fix test_follow_name_remove

* bump notify to 5.0.0-pre.15
* adjust PollWatcher::with_delay -> PollWatcher::with_config
2022-05-23 00:51:02 +02:00
Sylvestre Ledru
887f49ce2d
Merge pull request #3550 from thomasqueirozb/ls_gds
ls: implement --group-directories-first
2022-05-22 09:50:04 +02:00
Jeffrey Finkelstein
35fb4e6ea1 mktemp: include suffix in error message
Include the suffix in the error message produced by `mktemp` when
there are too few Xs in the template. Before this commit,

    $ mktemp --suffix=X aXX
    mktemp: too few X's in template 'aXX'

After this commit,

    $ mktemp --suffix=X aXX
    mktemp: too few X's in template 'aXXX'

This matches the behavior of GNU `mktemp`.
2022-05-21 21:59:06 -04:00
Thomas Queiroz
0b24839a1e
tests/ls: add --group-directories-first test 2022-05-21 18:57:53 -03:00
Thomas Queiroz
c4606266e4
tests/ls: update version sort test 2022-05-21 18:50:26 -03:00
Sylvestre Ledru
d92107362b
Merge pull request #3521 from jfinkels/mktemp-tmpdir-absolute-path
mktemp: correct error message on absolute path
2022-05-21 09:40:33 +02:00
Sylvestre Ledru
bda9f9f889
Merge pull request #3529 from ilkecan/mv-target-dir
mv: allow a single source with --target-directory
2022-05-21 09:40:16 +02:00
Jan Scheer
84480f892d
tail: add equivalent of stdin_is_pipe_or_fifo() for Windows
* add support to determine if stdin is readable on Windows
2022-05-19 22:55:47 +02:00
Jeffrey Finkelstein
6260333415 mktemp: fix error msg when suffix has path sep.
Correct the error message when the template argument contains a path
separator in its suffix. Before this commit:

    $ mktemp aXXX/b
    mktemp: too few X's in template 'b'

After this commit:

    $ mktemp aXXX/b
    mktemp: invalid suffix '/b', contains directory separator

This error message is more appropriate and matches the behavior of GNU
mktemp.
2022-05-19 15:46:04 +02:00
Jan Scheer
6a1cf72316
Merge branch 'main' into tail_notify 2022-05-18 14:28:19 +02:00
Jan Scheer
07231e6c6c
tail: fix handling of stdin redirects for macOS
On macOS path.is_dir() can be false for directories
if it was a redirect, e.g. ` tail < DIR`

* fix some tests for macOS

Cleanup:
* fix clippy/spell-checker
* fix build for windows by refactoring stdin_is_pipe_or_fifo()
2022-05-18 14:22:53 +02:00
Jeffrey Finkelstein
8a941db20a mktemp: correct error message on absolute path
Correct the error message produced by `mktemp` when `--tmpdir` is
given and the template is an absolute path:

    $ mktemp --tmpdir=a /XXX
    mktemp: invalid template, '/XXX'; with --tmpdir, it may not be absolute
2022-05-17 20:16:47 -04:00
Daniel Hofstetter
27dd59635a uucore: add InvalidSuffix to ParseSizeError 2022-05-17 15:37:49 +02:00
Jan Scheer
75a6641ced
Merge branch 'main' into tail_notify 2022-05-17 14:13:20 +02:00