Commit graph

2095 commits

Author SHA1 Message Date
Sylvestre Ledru
5a746a778f
Merge pull request #3938 from tertsdiepraam/dd-positional-args
`dd`: parse operands manually via positional args
2022-09-21 22:39:13 +02:00
Sylvestre Ledru
69b52b4a1b chroot: add a new test to verify that 'chroot / ls -al' works 2022-09-21 19:47:01 +02:00
Sylvestre Ledru
2e26e1d2bd chroot: implement --skip-chdir 2022-09-21 19:46:58 +02:00
Terts Diepraam
e377e4f046 dd: custom positional argument parsing 2022-09-21 18:41:12 +02:00
Sylvestre Ledru
3654efe8e7 chroot: add more tests 2022-09-21 14:53:50 +02:00
Sylvestre Ledru
a857002def
Merge pull request #3949 from niyaznigmatullin/cp-i_gnu_test
cp: fix `cp-i` GNU test
2022-09-18 22:06:12 +02:00
Terts Diepraam
8c839888e1
Merge pull request #3905 from Joining7943/refactor-tail
Refactor tail
2022-09-17 20:39:53 +02:00
Niyaz Nigmatullin
2ce999c959 cp: fix cp-i GNU test
`cp` in interactive mode used to write to stdout asking for
overwrite. GNU version writes to stderr.

Changed: write to stderr to make compatible with GNU.
2022-09-17 19:15:52 +03:00
Jeffrey Finkelstein
61345cbdc9 mktemp: respect TMPDIR environment variable
Change `mktemp` so that it respects the value of the `TMPDIR`
environment variable if no directory is otherwise specified in its
arguments. For example, before this commit

    $ TMPDIR=. mktemp
    /tmp/tmp.WDJ66MaS1T

After this commit,

    $ TMPDIR=. mktemp
    ./tmp.h96VZBhv8P

This matches the behavior of GNU `mktemp`.
2022-09-13 19:38:25 -04:00
Joining7943
951c51e740 tail: large refactoring and cleanup of the tail code base. See also #3905 for details 2022-09-13 22:54:36 +02:00
Sylvestre Ledru
78a9f6edf8
Merge pull request #3908 from tertsdiepraam/chroot-err-codes
`chroot`: set exit codes to 125, 126 or 127 for errors from chroot itself
2022-09-12 22:43:12 +02:00
Sylvestre Ledru
b44cf9cde9
Merge pull request #3910 from Joining7943/3895-fix-broken-pipe-error-in-utils
fix broken pipe error in tests/common/util
2022-09-12 22:42:36 +02:00
Niyaz Nigmatullin
8bd9427d0d tests/ls: added exit code to some test failures 2022-09-12 19:47:16 +03:00
Terts Diepraam
51bd8a2ba8 chroot: set exit codes to 125, 126 or 127 for errors from chroot itself 2022-09-11 12:02:54 +02:00
Terts Diepraam
9177cb7b24 all: add tests for usage error exit code 2022-09-10 20:59:42 +02:00
Joining7943
795ab1fb7e tests/common/util: Fix #3895 broken pipe error when using pipep input in UCommand 2022-09-10 11:10:53 +02:00
Joining7943
e860eb899e tests/common/util: Add test which provokes the broken pipe error 2022-09-10 11:10:53 +02:00
Niyaz Nigmatullin
999db68042 pr: migrate from chrono crate to time
It seems that `chrono` is the reason of deadlock or UB in android
CI. Also `chrono` had some security issues and wasn't maintained for
two years until March 2022, so other unstabilities can happen. Plus
`chrono` uses old `time` dependency.
2022-09-09 21:59:08 +03:00
Niyaz Nigmatullin
0d6383dd19 test_cp: comment out bad syscall failing piece of code for Android 2022-09-09 16:12:05 +03:00
Joining7943
2658f8ae5b tail: improve performance of piped stdin
Rewrite handling of stdin when it is piped and read input in chunks.

Fixes https://github.com/uutils/coreutils/issues/3842
2022-09-09 13:51:37 +02:00
Sylvestre Ledru
a8d1d73465 fix a test on cp counting the number of fd:
The testsuite runs in parallel, we have pipe, sockets
opened by other tests.
So, we take in account the various fd to increase the limit
2022-09-07 21:26:03 +02:00
Jan Scheer
88d3aee71c tail: fix offset for stdin redirect if multiple input files 2022-09-05 10:09:04 +02:00
Jan Scheer
74f359bd76 tail: use same-file crate to get a handle of stdin redirected file 2022-09-05 10:09:04 +02:00
Jan Scheer
942928b0ea tail: fix stdin redirect when file is not at its beginning
Previously, if stdin redirect pointed to a regular file,
tailing started at the beginning of the file. However,
tailing needs to start at the current position because this
is expected by tests/tail-2/start-middle.sh.

This fixes the issue by taking the current offset into account
while going backwards through the stdin redirected file.
2022-09-05 10:09:04 +02:00
Jan Scheer
92c3f60440 tail: fix stdin redirect (#3842)
This fixes a bug where calling `tail - < file.txt` would result
in invoking `unbounded_tail()`.
However, it is a stdin redirect to a seekable regular file and
therefore `bounded_tail` should be invoked as if `tail file.txt` had
been called.
2022-09-05 10:09:04 +02:00
Sylvestre Ledru
282774a3ef
Merge pull request #3853 from stefins/rm-write-protected
rm: added write-protected check for files
2022-08-29 17:03:24 +02:00
Owen Anderson
08d3da8f6c
Fix a TODO by making conv_block_unblock_helper consume the input. (#3787)
* Fix a TODO by making `conv_block_unblock_helper` consume the input.
2022-08-28 10:07:04 +02:00
Stefin
4c1c9ebf89 rm: change InteractiveMode::Default to InteractiveMode::PromptProtected
Signed-off-by: Stefin <stefin@pm.me>
2022-08-27 19:38:10 +05:30
Tavo Annus
09cfa44560 Fix tail panicing when seeking backwards
Previously `tail -c n file.txt` caused panic if n > sizeof file.txt.
Now it prints out whole file similarly to GNU tail.
2022-08-24 21:02:47 +03:00
Jeffrey Finkelstein
8458bf1387 Clippy fixes in multiple crates 2022-08-23 18:30:43 -04:00
Stefin
ad4eac867f rm: added test for rm_prompt_write_protected
Signed-off-by: Stefin <stefin@pm.me>
2022-08-23 21:17:48 +05:30
Niyaz Nigmatullin
306272bf60 unix_sockets is deprecated, use std::os::unix::net instead 2022-08-20 17:02:29 +03:00
Terts Diepraam
f861fc0854 stty: print special terminal information 2022-08-18 11:33:04 +02:00
Terts Diepraam
6896a85b41 test_stty: fix spell checker errors 2022-08-18 11:33:04 +02:00
Terts Diepraam
a23702caeb add some simple tests to stty (still failing) 2022-08-18 11:33:04 +02:00
Sylvestre Ledru
87e3899477
Merge pull request #3832 from tertsdiepraam/simplify-encoding-handling
Simplify invalid encoding handling
2022-08-17 18:59:59 +02:00
Terts Diepraam
ba713b6365 Simplify invalid encoding handling into two small methods of Args
The previous encoding handling was unnecessarily complex. This commit removes the enum that specifies the handling and instead has two separate methods to collect the strings either with lossy conversion or by ignoring invalidly encoded strings.
2022-08-17 15:20:20 +02:00
Terts Diepraam
5621502a95 all: remove accept_{any, complete, lossy} and ConversionResult
Outside of tests, only `accept_any` was used, meaning that this unnecessarily complicated the code. The behaviour of `accept_any` is now the default (and only) option.
2022-08-17 14:57:28 +02:00
Niyaz Nigmatullin
52d767ed5a test_pr: follow clippy advice 2022-08-17 13:13:27 +03:00
Przemysław Fuchs
3acbd1c048
dd: Error message of invalid args is matched with GNU (#3831) 2022-08-17 11:40:42 +02:00
Owen Anderson
9fad6fde35
Fix a bug in split where chunking would be skipped when the chunk size (#3800)
* Fix a bug in split where chunking would be skipped when the chunk size
happened to be an exact divisor of the buffer size used to read the
input stream.

The issue here was that file was being split byte-wise in chunks of 1G.
The input stream was being read in chunks of 8KB, which evenly divides
the chunk size. Because the check to allocate the next output chunk was
done at the bottom of the loop previously, it would never occur because
the current input chunk was fully consumed at that point. By moving the
check to the top of the loop (but still late enough that we know we have
bytes to write) we resolve this issue.

This scenario is unfortunately hard to write a test for, since we don't
explicitly control the input chunk size.

Fixes https://github.com/uutils/coreutils/issues/3790
2022-08-16 11:02:52 +02:00
Niyaz Nigmatullin
5d4ad4de13 tests/readlink: add test for delimiters usage 2022-08-16 08:21:43 +03:00
Niyaz Nigmatullin
6879ed7b34 tests/readlink: refactor added tests 2022-08-15 23:33:41 +03:00
Niyaz Nigmatullin
38add34d31 tests/readlink: fix for Windows 2022-08-15 23:31:45 +03:00
Niyaz Nigmatullin
a5e0a14415 tests/readlink: fix Windows "Not a directory" error message 2022-08-15 23:04:51 +03:00
Niyaz Nigmatullin
b74e2f9d9b tests/readlink: follow clippy advice 2022-08-15 22:48:35 +03:00
Niyaz Nigmatullin
e826ab5f0f tests/readlink: follow clippy advice 2022-08-15 22:47:03 +03:00
Niyaz Nigmatullin
df403334c0 tests/readlink: add spell-checker ignore 2022-08-15 22:47:03 +03:00
Niyaz Nigmatullin
94860f8af6 tests/realpath: add trailing slash usage tests 2022-08-15 22:47:03 +03:00
Niyaz Nigmatullin
1c6f71e0e1 tests/readlink: add tests for trailing slashes and canonicalize -e and
-f usages
2022-08-15 22:47:03 +03:00