Commit graph

9103 commits

Author SHA1 Message Date
Sylvestre Ledru
20f6b6d0c5
Fix the # of SKIP 2022-12-06 10:45:28 +01:00
ctsk
8a837dae21 Tick after creating progress bar to draw it 2022-12-06 10:36:52 +01:00
Kai M
42b9b7b62c
install: fix issue #3814 (#3950)
* install: fix installing one file when using -Dt options

* install: fix installing multiple files with -Dt

Code was missing the logic to create the target dir when multiple files
should be copied and target dir is given by -t option.
This simplifies the copy logic also when only one file should be copied
to the target dir.

* install: fix verbose output when using -D

Also adds a unit test to verify the same behaviour as the gnu tools.

* install: add more testcases for create leading dir

Tests various combinations of "-D" with and w/o "-t" when installing
either a single file or multiple files into a non existing directory.

  install -D file1 file2 (-t) not_existing_dir
  install -D file1 (-t) not_existing_dir/

Also fixes file formatting, spelling and adds some more test asserts.

* install: fix error for nonex. dir path ending on /

The install command failed with a different error message than the
original GNU install tool. Checking for a trailing slash fixes this.
Only works on unix though.

* install: add windows support when checking for '/'

* install.rs: fix spelling

* install.rs: add more tests regarding omitting dir

This increases the CI test coverage and also checks for more corner
cases to ensure uu_install is compliant with GNU's original.

    export C=coreutils/target/debug/

    rm -rf dir1 no-dir2 dir3 file
    mkdir -p dir1 dir3
    touch file

    ${C}install dir1/file1 dir1/.. no-dir2
    ${C}install dir1/file1 dir1/.. dir3
    ${C}install dir1/.. dir3

* install: improve test_install_missing_arguments

Also check that install returns the correct error messages, when only a
target directory is given via -t and that is is not created (-D option).

* install: rework the checks for missing file args

This ensures correct (GNU install like) behavior. Tests from the last
commit will pass now.
2022-12-06 09:11:23 +01:00
Sylvestre Ledru
c132535cf5 busybox: replicate the same output as GNU 2022-12-06 08:52:05 +01:00
Sylvestre Ledru
24340665ee
Merge pull request #4216 from jfinkels/cp-preserve-hardlinks-readability
cp: improve readability of preserve_hardlinks()
2022-12-06 08:44:44 +01:00
Sylvestre Ledru
321866aae9
Merge pull request #4215 from sylvestre/busybox3
factor: trim the input to fix some busybox results
2022-12-06 07:53:15 +01:00
Jeffrey Finkelstein
54a36df9ab dd: correct progress line if 1 byte written
Correct the progress report written by `dd` if exactly one byte is
written so that it says "1 byte" instead of "1 bytes".
2022-12-05 21:41:26 -05:00
Jeffrey Finkelstein
1a839fb2c4 cp: correct --verbose --parents output for dirs
This commit corrects the behavior of `cp -r --parents --verbose` when
the source path is a directory, so that it prints the copied ancestor
directories. For example,

    $ mkdir -p a/b/c d
    $ cp -r --verbose --parents a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'
2022-12-05 21:37:13 -05:00
Jeffrey Finkelstein
bd665ea44a cp: correct --verbose --parents output for files
This commit corrects the behavior of `cp --parents --verbose` when the
source path is a file so that it prints the copied ancestor
directories. For example,

    $ mkdir -p a/b d
    $ touch a/b/c
    $ cp --verbose --parents a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'

Fixes #3332.
2022-12-05 21:36:56 -05:00
Jeffrey Finkelstein
92e1bb98fe cp: improve readability of preserve_hardlinks()
Improve readability of the `preserve_hardlinks()` helper function by
reducing levels of nesting in the body of the function and making it
return a Boolean rather than mutating a Boolean argument.
2022-12-05 21:28:22 -05:00
Sylvestre Ledru
b7925465a8 factor: trim the input to fix some busybox results 2022-12-05 22:49:48 +01:00
Terts Diepraam
72d60f0869
Merge pull request #4214 from sylvestre/busybox2
Unbreak busybox + store the results
2022-12-05 13:29:24 +01:00
Sylvestre Ledru
70d686ace0
Merge pull request #4213 from jfinkels/cp-force-link
cp: force link between two files that exist
2022-12-05 08:57:58 +01:00
Sylvestre Ledru
2efda01c37
busybox: remove the warning in the CI 2022-12-05 08:47:55 +01:00
Jeffrey Finkelstein
682667fd1d cp: force link between two files that exist
Allow `cp` to link files that exist. For example,

    $ touch src dest
    $ cp -f --link src dest

Before this commit, an error was raised.
2022-12-04 19:36:05 -05:00
Sylvestre Ledru
c432c77233 move the cache earlier 2022-12-04 23:59:21 +01:00
Sylvestre Ledru
9ab9ec7fc5 extract and store busybox results 2022-12-04 23:59:18 +01:00
Sylvestre Ledru
92942722a7 bump busybox 2022-12-04 16:40:03 +01:00
Sylvestre Ledru
cc79be035a busybox: Add the file at the right place 2022-12-04 16:39:51 +01:00
Sylvestre Ledru
122cdc270d
Merge pull request #4211 from jfinkels/cp-file-perm-race.sh
cp: restrict permissions when copying FIFO
2022-12-04 10:12:08 +01:00
Sylvestre Ledru
8880d9d473
Merge pull request #4212 from jfinkels/fix-bsd-test
tests: skip inode check on BSD
2022-12-04 10:11:08 +01:00
Jeffrey Finkelstein
bf54fce055 tests: skip inode check on BSD 2022-12-03 23:50:39 -05:00
Jeffrey Finkelstein
6167de903e cp: restrict permissions when copying FIFO
When copying the contents of a named pipe (also known as a FIFO) via

    cp --preserve=ownership --copy-contents fifo fifo-copy

limit the permissions of the destination file while the contents are
being copied, and then restore the permissions to match those of the
source FIFO when all contents have been copied successfully.
2022-12-03 18:30:47 -05:00
jfinkels
4a4bb550e1
Merge pull request #3653 from jfinkels/dd-concise-byte-counts
dd: correct rendering of SI and IEC byte counts
2022-12-03 11:48:19 -05:00
Jeffrey Finkelstein
3a5b31a30f dd: correct rendering of SI and IEC byte counts
Adjust the rendering of the concise byte counts in both SI and IEC
units to better match the behavior of GNU dd.

Before this commit,

    $ 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

After this commit,

    $ head -c 1024 /dev/zero | dd > /dev/null
    2+0 records in
    2+0 records out
    1024 bytes (1.0 kB, 1.0 KiB) copied, 0.0 s, 1.0 MB/s

For comparison, GNU dd produces the following:

    $ head -c 1024 /dev/zero | dd > /dev/null
    2+0 records in
    2+0 records out
    1024 bytes (1.0 kB, 1.0 KiB) copied, 0.000332864 s, 3.1 MB/s
2022-12-03 10:14:00 -05:00
Sylvestre Ledru
3880b463fe
Merge pull request #4185 from jfinkels/uucore-sprintf-2
uucore: add sprintf() function
2022-12-03 10:21:09 +01:00
Sylvestre Ledru
75502aba93
Merge pull request #4136 from Joining7943/tail-test-runner
`tests/common/util`: Implement UChild, an abstraction for std::process::Child, to return UChild from run_no_wait instead
2022-12-03 10:18:25 +01:00
Sylvestre Ledru
818012e30b
Merge pull request #4193 from jfinkels/touch-relative-time
touch: add support for some relative times
2022-12-03 10:16:21 +01:00
Sylvestre Ledru
8e5d374ec2
Merge pull request #4197 from tertsdiepraam/cleanup-uucore-process
`uucore/process`: remove custom `ExitStatus`
2022-12-03 10:15:48 +01:00
Sylvestre Ledru
2facffa489
Merge pull request #4208 from jfinkels/cp-preserve-link
cp: preserve hard links when target already exists
2022-12-03 10:15:22 +01:00
Jeffrey Finkelstein
66ee373373 cp: preserve hard links when target already exists
Prevent a panic in `cp -a` when the target of a hard link already
exists in the target directory structure.

For example,

    $ mkdir -p src dest/src
    $ touch src/f dest/src/f
    $ ln src/f src/link
    $ cp -a src dest

The `cp` command now succeeds without error.
2022-12-02 23:50:18 -05:00
Joining7943
4a2ced5940 tests: Adjust some tests to use improved UChild. test_tac: Ignore pipe tests on windows.
Summary:
* Disable test_retry6 on android because of intermittent failures
* Use wait() instead of wait_with_output in test_cat, test_cp, test_sort
* tests/sort: Simplify usage of test_sigpipe_panic
* Fix tests in test_tee.

tests/tac:
There was a change in the `tests/common/util.rs` test api concerning piped input which may have
revealed a bug in the implementation of tac. Please see also
https://github.com/uutils/coreutils/pull/4136
2022-12-02 13:13:10 +01:00
Terts Diepraam
dc828fed2d uucore/process: remove custom ExitStatus 2022-12-02 12:25:14 +01:00
Sylvestre Ledru
3ca6139e0f
Merge pull request #4158 from tertsdiepraam/markdown-in-docs-v1
Markdown in docs v1
2022-12-02 09:39:33 +01:00
Joining7943
4f54eedb74 tests/util: Improve UChild. Cleanup redundant functions in util.rs.
A short summary of changes:

* Add some basic tests for UChild and the run methods.
* Try more often in a fixed interval to create the tempfile for CapturedOutput.
* Fix drop order of struct fields for better cleanup of temporary files/dirs.
* Mark UChild::wait_with_output and UChild::pipe_in_and_wait_with_output deprecated
* Make CapturedOutput private
* Panic in stdout_all, stdout_all_bytes etc. if output is not captured.
* Rename some methods, refactor, clean up, fix documentation, add try_... methods
2022-12-02 08:06:48 +01:00
Joining7943
982fb682e9 tests: Use UChild in tests. Rename run_no_wait_child to run_no_wait and return UChild
tests/tail:
* test_stdin_redirect_file:. Test fails now when assert_alive()!
The follow test `tail -f < file` where file's content is `foo` fails with:
    Assertion failed. Expected 'tail' to be running but exited with status=exit status: 0

I also tried on the command line and can confirm that tail isn't runnning when following by
descriptor. The test is deactivated until the implementation is fixed.

* test_follow_stdin_descriptor
* test_follow_stdin_explicit_indefinitely.
* test_follow_single
* test_follow_non_utf8_bytes
* test_follow_multiple
* test_follow_name_multiple
* test_follow_invalid_pid
* test_single_big_args
* test_retry3
* test_retry4
* test_retry5
* test_retry7
* test_retry8
* test_retry9
* test_follow_descriptor_vs_rename1
* test_follow_descriptor_vs_rename2
* test_follow_name_retry_headers
* test_follow_name_remove
* test_follow_name_truncate1
* test_follow_name_truncate2
* test_follow_name_truncate3
* test_follow_name_truncate4
* test_follow_truncate_fast
* test_follow_name_move_create1
* test_follow_name_move_create2
* test_follow_name_move1
* test_follow_name_move2
* test_follow_name_move_retry1
* test_follow_name_move_retry2
* test_follow_inotify_only_regular
* test_fifo
* test_illegal_seek

tests/cat:
* test_dev_full
* test_dev_full_show_all
* test_dev_random
* test_fifo_symlink

tests/dd:
* test_random_73k_test_lazy_fullblock
* test_sync_delayed_reader

tests/factor:
* test_parallel

tests/rm:
* test_rm_force_prompts_order
* test_rm_descend_directory
* test_rm_prompts

tests/seq:
* the helper run method

tests/sort:
* test_sigpipe_panic

tests/tee:
* the helper run_tee method

tests/tty:
* test_tty module

tests/yes:
* the helper run method
2022-12-02 08:06:45 +01:00
Joining7943
040a5e8301 tests/util: Implement UChild. UCommand: implement stderr_to_stdout, capture output as default
See pr #4136 (https://github.com/uutils/coreutils/pull/4136)
2022-12-02 08:05:05 +01:00
Joining7943
9b446bf261 tests/tail: Fix clippy warning same-item-push. Do not push same flag twice. 2022-12-02 08:05:05 +01:00
Jeffrey Finkelstein
d083fa19c2 uucore: add sprintf() function
Add an `sprintf()` function (and `printf()` function) to
`uucore::memo`.  The `sprintf()` function behaves roughly like the
standard Rust `format!()`, but follows our implementation of the GNU
`printf` formatting logic instead.
2022-12-02 07:48:36 +01:00
Sylvestre Ledru
403780a613
Merge pull request #4196 from cakebaker/cut_remove_unnecessary_return_type
cut: remove unnecessary return type
2022-12-02 07:47:49 +01:00
Sylvestre Ledru
3f43e7d1ea
Merge pull request #4202 from cakebaker/string_new
chore: standardize creation of empty strings
2022-12-02 07:47:27 +01:00
Daniel Hofstetter
05d12892f3 CI: enable manual_string_new lint 2022-12-01 13:49:23 +01:00
Daniel Hofstetter
6cc470920f numfmt: derive default impl for FormatOptions 2022-12-01 13:49:23 +01:00
Daniel Hofstetter
9a2174ba02 chore: standardize creation of empty strings 2022-12-01 13:49:23 +01:00
Terts Diepraam
efa0fd498b
Merge pull request #4179 from djedi23/verbose_and_progress
Suspend the progress bar before printing the copied files.
2022-11-30 13:19:58 +01:00
Terts Diepraam
558314e822
Merge pull request #4200 from uutils/sylvestre-patch-2
Move the dependabot to weekly
2022-11-30 12:32:39 +01:00
Sylvestre Ledru
46b7019ddf
Merge pull request #4195 from uutils/dependabot/cargo/clap_complete-4.0.6
build(deps): bump clap_complete from 4.0.5 to 4.0.6
2022-11-30 08:39:20 +01:00
Sylvestre Ledru
033969cf8f
Merge pull request #4181 from cakebaker/split_backticks_are_unbalanced
split: fix "backticks are unbalanced" warnings
2022-11-30 08:38:30 +01:00
Sylvestre Ledru
5efdc51609
Merge pull request #4191 from jfinkels/dd-sparse
dd: correctly set file size when conv=sparse
2022-11-30 08:38:09 +01:00
Terts Diepraam
b632ba8ff6 numfmt: update help to markdown syntax 2022-11-29 22:54:41 +01:00