Commit graph

1837 commits

Author SHA1 Message Date
Sylvestre Ledru
435c983b36
Merge pull request #3087 from water-ghosts/printf-general
printf - Update %g formatting to match GNU
2022-03-21 13:23:28 +01:00
Sylvestre Ledru
d3e2ad2d50
Merge pull request #3283 from jfinkels/timeout-usage-error
timeout: give usage error on invalid time interval
2022-03-21 09:27:58 +01:00
Sylvestre Ledru
af8726af43 ls: when -aA are provided, the order matters 2022-03-20 23:23:17 +01:00
Jeffrey Finkelstein
c39c917db7 sleep: give usage error on invalid time interval
For example,

    $ sleep xyz
    sleep: invalid time interval 'xyz'
    Try 'sleep --help' for more information.

This matches the behavior of GNU sleep.
2022-03-20 15:21:50 -04:00
Jeffrey Finkelstein
e849aaf846 timeout: give usage error on invalid time interval 2022-03-20 15:16:03 -04:00
Sylvestre Ledru
04b219bdef
Merge pull request #3229 from uutils/dependabot/cargo/clap-3.1.6
build(deps): bump clap from 3.0.10 to 3.1.6
2022-03-20 17:44:33 +01:00
Jeffrey Finkelstein
b79ff6b4fd split: avoid writing final empty chunk with -C
Fix a bug in which a final empty file was written when using `split
--line-bytes` mode.
2022-03-20 09:30:58 -04:00
Sam Caldwell
f40fecf86d Add UError impl for clap::Error 2022-03-20 13:50:39 +01:00
Sam Caldwell
efd627bb20 cp: only allow directory for -t 2022-03-20 13:50:39 +01:00
Eli Youngs
a0bd88b51b Add comments and an additional test 2022-03-20 00:44:09 -07:00
Jeffrey Finkelstein
95f58fbf3c split: handle no final newline with --line-bytes
Fix a panic due to out-of-bounds indexing when using `split
--line-bytes` with an input that had no trailing newline.
2022-03-19 23:50:02 -04:00
Jeffrey Finkelstein
0a226524a6 split: elide all chunks when input file is empty
Fix a bug in the behavior of `split -e -n NUM` when the input file is
empty. Previously, it would panic due to overflow when subtracting 1
from 0. After this change, it will terminate successfully and produce
no output chunks.
2022-03-19 14:32:28 -04:00
Sylvestre Ledru
3c88fb460b
Merge branch 'main' into dependabot/cargo/clap-3.1.6 2022-03-19 09:26:05 +01:00
Jeffrey Finkelstein
ce2a026ff8 sleep: use Duration::saturating_add to sum times
Use `Duration::saturating_add()` to avoid a panic due to overflow when
adding the durations provided as command-line arguments.
2022-03-18 23:15:02 -04:00
Jeffrey Finkelstein
388cb6c83a uucore: use Duration::saturating_mul in parse_time
Use `Duration::saturating_mul()` to avoid a panic due to overflow in
`uucore::parse_time::from_str()`. This change prevents panic on very
large arguments to timeout and sleep.
2022-03-18 23:15:02 -04:00
chordtoll
72ce815d87 Add correct set of tests, fix typo in flags to test, write test to confirm additive flags 2022-03-18 20:45:04 +01:00
chordtoll
b77b3cba55 dd: implement iseek + oseek flags
These are the first half of changes needed to pass the dd/bytes.sh tests:
- Add iseek and oseek options (additive with skip and seek options)
- Implement tests for the new flags, matching those from dd/bytes.sh
2022-03-18 20:45:04 +01:00
Sylvestre Ledru
9796e01df6
Revert "split: implement round-robin arg to --number" 2022-03-18 14:45:29 +01:00
Terts Diepraam
20212be4c8 fix clippy errors related to clap upgrade from 3.0.10 to 3.1.6 2022-03-17 22:46:56 +01:00
Sylvestre Ledru
a5948ce11b
Merge pull request #3155 from jtracey/gecos-off-by-one
pinky: fix off-by-one in GECOS parsing
2022-03-17 13:35:05 +01:00
Jeffrey Finkelstein
18bfd1ac68 split: implement round-robin arg to --number
Implement distributing lines of a file in a round-robin manner to a
specified number of chunks. For example,

    $ (seq 1 10 | split -n r/3) && head -v xa[abc]
    ==> xaa <==
    1
    4
    7
    10

    ==> xab <==
    2
    5
    8

    ==> xac <==
    3
    6
    9
2022-03-15 18:22:44 -04:00
kimono-koans
fa6af85b8e
ls: Fix display of inodes and add allocation size feature (#3052) 2022-03-15 16:27:43 +01:00
Sylvestre Ledru
748d414946
Merge pull request #3258 from cakebaker/fix_exclude_type_panic
df: fix panic when using -x argument (#3257)
2022-03-15 16:24:15 +01:00
Sylvestre Ledru
9dea9b4b83
Merge branch 'main' into mkdir-fix 2022-03-15 12:03:47 +01:00
Ryan Gonzalez
2dc3d867d8 cp: Avoid following a destination symlink with -P
Previously, given 'cp -P a b', where 'a' and 'b' were both symlinks, cp
would end up replacing the target of 'b'.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2022-03-14 17:49:42 -05:00
Daniel Hofstetter
433504949d df: fix panic when using -x argument (#3257)
Also allow multiple '-x' options
2022-03-14 10:32:42 +01:00
Sylvestre Ledru
dd6d29f389
Merge pull request #3248 from sylvestre/nproc
nproc: Improve the GNU compat
2022-03-14 08:32:40 +01:00
Sylvestre Ledru
24b4af768c nproc: Improve the support of OMP_NUM_THREADS 2022-03-13 18:33:16 +01:00
Jeffrey Finkelstein
1aa6fd1468 timeout: fix bug in --preserve-status mode
Fix a bug where `timeout --preserve-status` was not correctly
preserving the status code of the child process if it timed out. When
that happens, the status code of the child process is considered to be
the signal number (in this case, `SIGTERM`). The exit status of
`timeout` is then 128 plus the numeric code associated with `SIGTERM`.
2022-03-12 19:53:11 -05:00
Sylvestre Ledru
2c6bbcf716 nproc: support --ignore=' 1' as GNU 2022-03-12 19:23:37 +01:00
Sylvestre Ledru
bfd1e14137
Merge pull request #3204 from jfinkels/split-line-bytes
split: implement --line-bytes option
2022-03-12 09:45:07 +01:00
Sylvestre Ledru
2cc951ae79
Merge pull request #3218 from sylvestre/timeout-test
timeout: add a test for empty arg
2022-03-12 09:43:36 +01:00
Eli Youngs
565af8237b Fix formatting 2022-03-11 23:43:59 +01:00
Eli Youngs
e23219289a Simplify test cases 2022-03-11 23:43:59 +01:00
Eli Youngs
2afa9cd1a0 printf - Update %g formatting to match GNU 2022-03-11 23:43:59 +01:00
Kartik Sharma
5c5f4ca6ad
df: Adds support for mount path prefix matching and input path (#3161)
* Adds support for mount path prefix matching and input path
canonicalization

- Sorts mount paths in reverse lexicographical order
- Canonicalize all paths and clear invalid paths
- Checking of mount path prefix matches input path
2022-03-11 09:36:34 +01:00
Sylvestre Ledru
1795272473
Merge pull request #3176 from jfinkels/df-output-columns-2
df: implement the --output command-line argument
2022-03-11 09:26:17 +01:00
Jeffrey Finkelstein
77d92883c7 split: implement --line-bytes option
Implement the `--line-bytes` option to `split`. In this mode, the
program tries to write as many lines of the input as possible to each
chunk of output without exceeding a specified byte limit. The new
`LineBytesChunkWriter` struct represents this functionality.
2022-03-10 22:51:49 -05:00
Jeffrey Finkelstein
c0cd017706 tests: update test_df.rs to use --output argument 2022-03-10 22:50:15 -05:00
Jeffrey Finkelstein
ec048b3857 df: implement the --output command-line argument
Implement the `--output` command-line argument, which allows
specifying an exact sequence of columns to display in the output
table. For example,

    $ df --output=source,fstype | head -n3
    Filesystem       Type
    udev             devtmpfs
    tmpfs            tmpfs

(The spacing does not exactly match the spacing of GNU `df` yet.)

Fixes #3057.
2022-03-10 22:50:15 -05:00
Jeffrey Finkelstein
b42168e9dc Clippy fixes in multiple crates 2022-03-10 22:31:21 -05:00
Sylvestre Ledru
2e860e7048
Merge pull request #3116 from nickd0/printf-round-fix
printf: fix printf sci notation round up
2022-03-09 19:47:52 +01:00
Sylvestre Ledru
3955354b3a timeout: add a test for empty arg 2022-03-09 19:45:43 +01:00
Daniel Hofstetter
3317fb9924 df: always round up usage percentage (#3208) 2022-03-08 15:13:05 +01:00
Justin Tracey
687dcaef9f users and who: ignore failing tests for now 2022-03-07 12:32:07 -05:00
Justin Tracey
f52f655934 pinky: improve tests 2022-03-07 12:32:07 -05:00
Sylvestre Ledru
37a0a74c19
Merge pull request #3033 from water-ghosts/cp-lb
cp: Create backup before hardlink
2022-03-07 08:18:36 +01:00
Sylvestre Ledru
76cb746aca
Merge pull request #3191 from jfinkels/df-block-size-heading
df: fix block size header for multiples of 1024
2022-03-07 08:09:03 +01:00
Nick Donald
a74ffac19e printf: fix printf sci notation round up 2022-03-07 07:01:21 +01:00
Sylvestre Ledru
b9953eb883
Merge pull request #3122 from xxyzz/chmod
chmod: replace walkdir with std::fs
2022-03-06 23:01:50 +01:00
Devin Gunay
103dffc12e
touch: implement - (#3158) 2022-03-06 23:00:42 +01:00
353fc443 aka Seagull
8ccc45c68c
mkdir: recursive reporting of created directories in verbose mode (#3217) 2022-03-06 21:36:08 +01:00
xxyzz
ce385be575
chmod: ignore symbolic links during recursive directory traversal 2022-03-06 09:38:39 +08:00
xxyzz
3272a590db
test_chmod: update expected results of test_chmod_recursive
The test succeeds before because the files are read before the permission change and that's inconsistent with GNU chmod.
2022-03-06 08:40:36 +08:00
xxyzz
9083f236da
test_chmod: add read permission recursively test 2022-03-06 08:40:36 +08:00
Jeffrey Finkelstein
5cf7139467 df: fix block size header for multiples of 1024
Correct the column header printed by `df` when the `--block-size`
argument has a value that is a multiple of 1024. After this commit,
the header looks like "1K" or "4M" or "117G", etc., depending on the
particular value of the block size. For example:

    $ df --block-size=1024 | head -n1
    Filesystem                1K-blocks     Used Available Use% Mounted on
    $ df --block-size=2048 | head -n1
    Filesystem                2K-blocks     Used Available Use% Mounted on
    $ df --block-size=3072 | head -n1
    Filesystem                3K-blocks     Used Available Use% Mounted on
    $ df --block-size=4096 | head -n1
    Filesystem                4K-blocks     Used Available Use% Mounted on
2022-03-05 11:47:45 -05:00
Sylvestre Ledru
430a6650e0
Merge branch 'main' into cp-lb 2022-03-05 10:33:43 +01:00
Jeffrey Finkelstein
d0ebd1c9d0 df: add support for --total option
Add support for the `--total` option to `df`, which displays the total
of each numeric column. For example,

    $ df --total
    Filesystem            1K-blocks     Used Available Use% Mounted on
    udev                    3858016        0   3858016   0% /dev
    ...
    /dev/loop14               63488    63488         0 100% /snap/core20/1361
    total                 258775268 98099712 148220200  40% -
2022-03-05 10:29:46 +01:00
Sylvestre Ledru
f3bd1f3020 Add onehundredlines in the spell ignore 2022-03-05 10:27:51 +01:00
Jeffrey Finkelstein
ee36dea1a9 split: implement outputting kth chunk of file
Implement `-n l/k/N` option, where the `k`th chunk of the input file
is written to stdout. For example,

    $ seq -w 0 99 > f; split -n l/3/10 f
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
2022-03-05 10:27:51 +01:00
Terts Diepraam
bb379b5384 pr: fix heuristic for number-lines argument (#3109) 2022-03-05 10:26:12 +01:00
Sylvestre Ledru
8df4f0bb4d
Merge branch 'main' into cp-lb 2022-03-04 20:39:23 +01:00
Sylvestre Ledru
25f0423399
Merge branch 'main' into mkdir-fix 2022-03-04 20:38:06 +01:00
Hanif Ariffin
30a174e6e4
realpath: Error when resolved symlink is absolute and ENOENT (#3037)
* realpath: Match behavior where resolving symlinks with absolute path is an error if ENOENT

This PR changes `realpath` to match the behavior in GNU where,

```shell
hbina@akarin ~/Documents> mkdir dir1
hbina@akarin ~/Documents> mkdir dir2
hbina@akarin ~/Documents> touch dir2/bar
hbina@akarin ~/Documents> ln -s ../dir2/bar dir1/foo1
hbina@akarin ~/Documents> ln -s /dir2/bar dir1/foo2
hbina@akarin ~/Documents> ln -s ../dir2/baz dir1/foo3
hbina@akarin ~/Documents> realpath ./dir1/foo1 ./dir1/foo2 ./dir1/foo3
/home/hbina/Documents/dir2/bar
realpath: ./dir1/foo2: No such file or directory
/home/hbina/Documents/dir2/baz
```

Currently, our `realpath` will happily print the second one out,

```shell
hbina@akarin ~/Documents> ~/git/uutils/target/debug/coreutils realpath ./dir1/foo1 ./dir1/foo2 ./dir1/foo3
/home/hbina/Documents/dir2/bar
/dir2/bar
/home/hbina/Documents/dir2/baz
```

Closes https://github.com/uutils/coreutils/issues/3036

Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
2022-03-03 23:06:15 +01:00
Sylvestre Ledru
63cf0d20b4
Merge branch 'main' into cp-lb 2022-03-03 23:02:57 +01:00
Eli Youngs
eace4bc907
cp: Support copying FIFOs with -r (#3032) 2022-03-03 22:58:27 +01:00
Terts Diepraam
618a268f61
Merge pull request #3081 from HeroicKatora/main
Discuss seq parsing
2022-03-03 22:50:32 +01:00
Sylvestre Ledru
66e9956595
Merge pull request #3156 from jfinkels/dd-cbs-blocks
dd: pad partial record with spaces in some cases
2022-03-03 22:35:58 +01:00
Sylvestre Ledru
346cfa060b
Merge pull request #2980 from jfinkels/split-lines-2
split: add support for "-n l/NUM" option to split
2022-03-01 10:13:44 +01:00
Sylvestre Ledru
bbef777c8c
Merge pull request #2998 from tertsdiepraam/cp-override-args
`cp`: override args instead of having them conflict
2022-02-28 14:47:53 +01:00
Sylvestre Ledru
3b48d1273a
Merge pull request #3187 from ndd7xv/install-error-msg
install: better error messages when handling invalid arguments
2022-02-26 18:57:17 +01:00
Terts Diepraam
9aca050e4a cp: override args
These arguments should not have been in conflict with each other, but silently override each other.
2022-02-26 10:37:58 +01:00
ndd7xv
47be40afae install: add tests for error handling 2022-02-25 21:17:43 -05:00
DevSabb
b8a3795d95
tr: fix octal interpretation of repeat count string (#3178)
* tr: fix octal interpretation of repeat count string

* tr: fix formatting errors

* tr: fix formatting issues 2

* tr: attempt to bypass spell check error

* tr: fix spell check errors attempt 2

* tr: formatting fixes

Co-authored-by: DevSabb <devsabb@local>
2022-02-25 12:11:53 +01:00
Terts Diepraam
722c5d268f fix Rust 1.59 clippy lints 2022-02-25 09:39:48 +01:00
Pyokyeong Son
31d91f36b9 test/mkdir: fixed assert types to both mode_t 2022-02-24 07:43:53 +00:00
Pyokyeong Son
fe9e9e6689 test/mkdir: made umask variable mode_t 2022-02-24 07:26:46 +00:00
Jeffrey Finkelstein
dbbee573ab split: add support for "-n l/NUM" option to split
Add support for `split -n l/NUM`. Previously, `split` only supported
`-n NUM`, which splits a file into `NUM` chunks by byte. The `-n
l/NUM` strategy splits a file into `NUM` chunks without splitting
lines across chunks.
2022-02-22 18:44:08 -05:00
Omer Tuchfeld
0ce22f3a08 Improve coverage / error messages from parse_size PR
https://github.com/uutils/coreutils/pull/3084 (2a333ab391) had some
missing coverage and was merged before I had a chance to fix it.

This PR adds some coverage / improved error messages that were missing
from that previous PR.
2022-02-22 22:09:45 +01:00
Omer Tuchfeld
f3895124b9 Remove impractical test creating a file too large 2022-02-22 14:23:46 +01:00
Omer Tuchfeld
fa60898354 Adjust 32-bit tests for tail,split,truncate,head 2022-02-22 13:49:20 +01:00
Sylvestre Ledru
775588fb18
Merge pull request #3127 from xxyzz/df
df: some option changes
2022-02-21 19:08:56 +01:00
Jeffrey Finkelstein
9f367b72e6 dd: pad partial record with spaces in some cases
If `conv=block,sync` command-line arguments are given and there is at
least one partial record read from the input (for example, if the
length of the input is not divisible by the value of the `ibs`
argument), then output an extra block of `cbs` spaces.

For example, no extra spaces are printed in this example because the
input is of length 10, a multiple of `ibs`:

    $ printf "012\nabcde\n" \
    > | dd ibs=5 cbs=5 conv=block,sync status=noxfer \
    > && echo $
    012  abcde$
    2+0 records in
    0+1 records out

But in this example, 5 extra spaces are printed because the length of
the input is not a multiple of `ibs`:

    $ printf "012\nabcdefg\n" \
    > | dd ibs=5 cbs=5 conv=block,sync status=noxfer \
    > && echo $
    012  abcde     $
    2+1 records in
    0+1 records out
    1 truncated record

The number of spaces printed is the size of the conversion block,
given by `cbs`.
2022-02-21 13:00:11 -05:00
Sylvestre Ledru
419abec4e5
Merge pull request #3148 from jfinkels/dd-of-dev-null
dd: don't error when outfile is /dev/null
2022-02-21 17:10:42 +01:00
Sylvestre Ledru
bc3f540a1b
Merge pull request #2965 from tertsdiepraam/test-wsl-exec-permission
`test`: fix wsl executable permission
2022-02-20 10:36:13 +01:00
Sylvestre Ledru
73051809a7
Merge pull request #3018 from Narasimha1997/fix-cp-recursion
Fix: Avoid infinite recursion when source and destinations are same while using `cp -R`
2022-02-20 10:34:34 +01:00
Sylvestre Ledru
42eba6c5b2
Merge pull request #3107 from jfinkels/split-elide-empty-files
split: add support for -e argument
2022-02-20 10:32:57 +01:00
Sylvestre Ledru
6bf575ad56
Merge branch 'main' into cp-lb 2022-02-20 10:31:13 +01:00
Jeffrey Finkelstein
6900638ac6 dd: don't error when outfile is /dev/null
Prevent `dd` from terminating with an error when given the
command-line argument `of=/dev/null`. This commit allows the call to
`File::set_len()` to result in an error without causing the process to
terminate prematurely.
2022-02-19 10:29:09 -05:00
Pyokyeong Son
553c22d33d test/mkdir: reverted mkdir testing delete 2022-02-19 05:46:11 +00:00
Pyokyeong Son
8ffe367dd8 test/mkdir: added testing for umask compliance
- tests for all permission combinations
2022-02-19 05:37:56 +00:00
Jeffrey Finkelstein
766c85fb5e dd: correct order and phrasing of truncated record
Place the "truncated records" line below the "records out" line in the
status report produced by `dd` and properly handle the singularization
of the word "record" in the case of 1 truncated record. This matches
the behavior of GNU `dd`.

For example

    $ printf "ab" | dd cbs=1 conv=block status=noxfer > /dev/null
    0+1 records in
    0+1 records out
    1 truncated record

    $ printf "ab\ncd\n" | dd cbs=1 conv=block status=noxfer > /dev/null
    0+1 records in
    0+1 records out
    2 truncated records
2022-02-18 23:49:33 -05:00
Jeffrey Finkelstein
89f428b44f dd: remove spurious zero multiplier warning
Fix a bug in which `dd` was inappropriately showing a warning about a
"0x" multiplier when there was no "x" character in the argument.
2022-02-17 19:06:05 -05:00
Jeffrey Finkelstein
6718d97f97 split: add support for -e argument
Add the `-e` flag, which indicates whether to elide (that is, remove)
empty files that would have been created by the `-n` option.

The `-n` command-line argument gives a specific number of chunks into
which the input files will be split. If the number of chunks is
greater than the number of bytes, then empty files will be created for
the excess chunks. But if `-e` is given, then empty files will not be
created.

For example, contrast

    $ printf 'a\n' > f && split -e -n 3 f && cat xaa xab xac
    a
    cat: xac: No such file or directory

with

    $ printf 'a\n' > f && split -n 3 f && cat xaa xab xac
    a
2022-02-17 19:03:51 -05:00
Terts Diepraam
e1a611374a
Merge pull request #2981 from jfinkels/split-hex-numbers
split: add support for -x option (hex suffixes)
2022-02-17 23:20:58 +01:00
xxyzz
c16c06ea0d
df: add output option's valid field names 2022-02-17 13:43:59 +08:00
Jeffrey Finkelstein
ba1ce7179b dd: move unit tests into dd.rs and test_dd.rs
Clean up unit tests in the `dd` crate to make them easier to
manage. This commit does a few things.

* move test cases that test the complete functionality of the `dd`
  program from the `dd_unit_tests` module up to the
  `tests/by-util/test_dd.rs` module so that they can take advantage of
  the testing framework and common testing tools provided by uutils,
* move test cases that test internal functions of the `dd`
  implementation into the `tests` module within `dd.rs` so that they
  live closer to the code they are testing,
* replace test cases defined by macros with test cases defined by
  plain old functions to make the test cases easier to read at a
  glance.
2022-02-15 21:50:48 -05:00
Jeffrey Finkelstein
e598bf0835 tests: add CmdResult::stdout_is_fixture_bytes()
Add helper method `CmdResult::stdout_is_fixture_bytes()`, which is
like `stdout_is_fixture()` but compares stdout to the raw bytes of a
given file instead of decoding the contents of the file to a UTF-8
string.
2022-02-15 21:50:48 -05:00
Sylvestre Ledru
67cee26abe
Merge pull request #3003 from tertsdiepraam/ls-fix-another-flaky-test
`ls`: fix flaky test `test_ls_io_errors`
2022-02-15 20:11:48 +01:00
DevSabb
63fa3c81ed fix failure in test_split 2022-02-14 20:41:58 -05:00
DevSabb
6d6371741a
include io-blksize parameter (#3064)
* include io-blksize parameter

* format changes for including io-blksize

Co-authored-by: DevSabb <devsabb@local>
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2022-02-14 19:47:18 +01:00
Terts Diepraam
351a56d3fd
Merge pull request #3133 from sylvestre/issue-3132
expr: Use chars().count() as we can have some multibytes chars
2022-02-13 17:48:37 +01:00
Jeffrey Finkelstein
a4955b4e06 split: add support for -x option (hex suffixes)
Add support for the `-x` command-line option to `split`. This option
causes `split` to produce filenames with hexadecimal suffixes instead
of the default alphabetic suffixes.
2022-02-13 11:18:37 -05:00
Sylvestre Ledru
7225fb6c24 expr: Use chars().count() as we can have some multibytes chars
Partially fixes #3132
Fixes one of the test of tests/misc/expr-multibyte
2022-02-13 14:19:25 +01:00
Terts Diepraam
85c4fb3981
Merge pull request #3129 from jfinkels/dd-partial-records
dd: correctly account for partial record written
2022-02-13 12:52:09 +01:00
Jeffrey Finkelstein
3ada6af19d dd: correctly account for partial record written
Correct the accounting for partial records written by `dd` to the
output file. After this commit, if fewer than `obs` bytes are written,
then that is counted as a partial record. For example,

    $ printf 'abc' | dd bs=2 status=noxfer > /dev/null
    1+1 records in
    1+1 records out

That is, one complete record and one partial record are read from the
input, one complete record and one partial record are written to the
output. Previously, `dd` reported two complete records and zero
partial records written to the output in this case.
2022-02-12 22:38:25 -05:00
Jeffrey Finkelstein
b6d1aa3e73 df: always produce the same order in output table
Change the `filter_mount_list()` function so that it always produces
the same order of `MountInfo` objects. This change ultimately results
in `df` printing its table of filesystems in the same order on each
execution. Previously, the table was in an arbitrary order because the
`MountInfo` objects were read from a `HashMap`.

Fixes #3086.
2022-02-12 21:14:14 -05:00
Sylvestre Ledru
f9e04ae5ef
Merge pull request #2966 from allan-silva/wc-files0-from-opt
wc: implement files0-from option
2022-02-12 19:05:05 +01:00
Sylvestre Ledru
0ed5e2c884
Merge pull request #2957 from jfinkels/head-preserve-no-final-newline
head: don't add trailing newline to end of file that didn't originally have one
2022-02-12 19:03:13 +01:00
Sylvestre Ledru
142c24e579
Merge pull request #2982 from Dr-Emann/paste_cleanup
paste: Fixes and cleanup
2022-02-12 19:00:39 +01:00
alextibbles
d9c2acc2ed
update to sha 0.10.0 (#3110)
* update to sha 0.10.0

* correct formatting
2022-02-12 18:12:02 +01:00
Sylvestre Ledru
c2e3f4109c
Merge pull request #2944 from jfinkels/truncate-fifo
truncate: error when trying to truncate a fifo
2022-02-12 11:36:17 +01:00
Sylvestre Ledru
090fb07361
Merge pull request #3066 from jfinkels/dd-skip-beyond-file
dd: show warning if skipping past end of input
2022-02-12 11:34:06 +01:00
Sylvestre Ledru
6b6d5ee7db
Merge pull request #2827 from jfinkels/split-std-io-copy
split: use std::io::copy() with new writer implementation to improve maintainability and speed
2022-02-12 11:33:12 +01:00
Sylvestre Ledru
cccc6b8524
Merge pull request #3089 from jfinkels/tests-stderr-only-bytes
tests: fix no_stderr check in stderr_only_bytes()
2022-02-12 11:32:35 +01:00
Sylvestre Ledru
463e160d2f
Merge pull request #3117 from jfinkels/touch-no-deref-no-file
touch: show error on -h with nonexistent file
2022-02-12 11:27:46 +01:00
Jeffrey Finkelstein
f37e78c25a touch: show error on -h with nonexistent file
Show an error message when running `touch -h` on a nonexistent file.
2022-02-11 20:58:16 -05:00
353fc443
c2bb9dd433
Fix clippy octal-escapes warning 2022-02-11 13:02:06 +00:00
Sylvestre Ledru
080cb2b6f9
Merge pull request #3108 from DestroyerXyz/blake3
hashsum: Add BLAKE3 to Hashing Algorithms
2022-02-11 11:40:10 +01:00
Jeffrey Finkelstein
2f65b29866 split: error when --additional-suffix contains /
Make `split` terminate with a usage error when the
`--additional-suffix` argument contains a directory separator
character.
2022-02-10 19:33:33 -05:00
Sylvestre Ledru
e818fd2b98
Merge pull request #3092 from jtracey/join-performance
join: improve performance
2022-02-10 22:39:12 +01:00
Abhishek C Sharma
3f6fe7f388
ls: add new optional arguments to --classify flag (#3041)
* ls: add new optional arguments to --classify flag

The --classify flag in ls now takes an option when argument
that may have the values always, auto and none.

Modified clap argument to allow an optional parameter and
changed the classify flag value parsing logic to account for
this change.

* ls: add test for indicator-style, ind and classify with value none

* ls: require option paramter to --classify to use a = to specify flag value

* ls: account for all the undocumented possible values for the --classify flag

Added the other values for the --classify flag along with modifications to tests.
Also documented the inconsistency between GNU coreutils because we accept the
flag value even for the short version of the flag.
2022-02-10 21:35:20 +01:00
Shreyans Jain
3176ad5c1b
tests/hashsum: Fix missing space in checkfile 2022-02-10 13:55:53 +05:30
Shreyans Jain
30d7a4b167
hashsum: Add BLAKE3 to Hashing Algorithms
Signed-off-by: Shreyans Jain <shreyansthebest2007@gmail.com>
2022-02-10 12:46:44 +05:30
Jeffrey Finkelstein
1d7e1b8732 split: use ByteChunkWriter and LineChunkWriter
Replace `ByteSplitter` and `LineSplitter` with `ByteChunkWriter` and
`LineChunkWriter` respectively. This results in a more maintainable
design and an increase in the speed of splitting by lines.
2022-02-08 22:57:57 -05:00
Jeffrey Finkelstein
ca7af808d5 tests: correct a test case for split
Correct the `test_split::test_suffixes_exhausted` test case so that it
actually exercises the intended behavior of `split`. Previously, the
test fixture contained 26 bytes. After this commit, the test fixture
contains 27 bytes. When using a suffix width of one, only 26 filenames
should be available when naming chunk files---one for each lowercase
ASCII letter. This commit ensures that the filenames will be exhausted
as intended by the test.
2022-02-08 22:53:57 -05:00
Sylvestre Ledru
47b12b31a6
Merge pull request #3006 from jfinkels/split-errors
split: correct error message on invalid arg. to -a
2022-02-08 20:51:32 +01:00
Sylvestre Ledru
daaae90113
Merge branch 'main' into dd-skip-beyond-file 2022-02-08 20:46:07 +01:00
Sylvestre Ledru
936ac0db38
Merge pull request #3053 from snobee/stat-handle-negative-time
stat: allow formatting of negative numbers
2022-02-08 20:45:21 +01:00
Sylvestre Ledru
9c813be5f1
Merge pull request #3076 from jfinkels/dd-seek-truncate
dd: truncate to specified seek length
2022-02-08 11:16:15 +01:00
Justin Tracey
b873d46ca0 join: flush stdout before final error message 2022-02-07 22:32:02 -05:00
Justin Tracey
bf67c5d981 join: add tests for --check-order and stdout error 2022-02-07 22:26:27 -05:00
Narasimha Prasanna HN
0379fca260 Fix merge conflict in tests/by-util/test_cp.rs 2022-02-07 23:26:06 +05:30
Jeffrey Finkelstein
9f8ec676c5 dd: show warning if skipping past end of input
Show a warning if the `skip=N` command-line argument would cause `dd`
to skip past the end of the input. For example:

    $ printf "abcd" | dd bs=1 skip=5 count=0 status=noxfer
    'standard input': cannot skip to specified offset
    0+0 records in
    0+0 records out
2022-02-06 20:10:42 -05:00
Jeffrey Finkelstein
e5361a8c11 split: correct error message on invalid arg. to -a
Correct the error message displayed on an invalid parameter to the
`--suffix-length` or `-a` command-line option.
2022-02-06 20:09:29 -05:00
Jeffrey Finkelstein
e6a63a78f6 tests: fix no_stderr check in stderr_only_bytes()
Fix a bug in `stderr_only_bytes()` where it was unintentionally
checking `no_stderr()` when it should have been checking
`no_stdout()`.
2022-02-06 18:03:13 -05:00
Jeffrey Finkelstein
fec662a623 dd: show warning when using 0x size multiplier
Show a warning when a block size includes "0x" since this is
ambiguous: the user may have meant "multiply the next number by zero"
or they may have meant "the following characters should be interpreted
as a hexadecimal number".
2022-02-06 17:13:15 -05:00
Sylvestre Ledru
1f7c08d87b
Merge pull request #3028 from jfinkels/dd-multipliers
dd: add support for 'b' and 'x' multipliers in numeric arguments
2022-02-06 22:03:54 +01:00
Sylvestre Ledru
16b397a648
Merge pull request #3029 from hbina/hbina-test_ls_order_time-is-flaky
test_ls: Do not rely on the system time of metadata'access time
2022-02-06 22:03:31 +01:00
Sylvestre Ledru
1ac45c9961
Merge pull request #3044 from water-ghosts/cp-dir-vs-file
cp: Fail when copying a directory to a file
2022-02-06 22:01:37 +01:00
Andreas Molzer
a2e9329918 seq: Allow option to receive immediate arguments
WIP: this needs to be adjusted
2022-02-06 09:45:38 -06:00
Andreas Molzer
66733ca994 seq: Add difficult cases to test suite 2022-02-06 09:45:37 -06:00
Jeffrey Finkelstein
1af709f642 dd: truncate to specified seek length
When specifying `seek=N` and *not* specifying `conv=notrunc`, truncate
the output file to `N` blocks instead of truncating it to zero before
starting to write output. For example

    $ printf "abc" > outfile
    $ printf "123" | dd bs=1 skip=1 seek=1 count=1 status=noxfer of=outfile
    1+0 records in
    1+0 records out
    $ cat outfile
    a2

Fixes #3068.
2022-02-05 16:07:44 -05:00
Sylvestre Ledru
2ffc5f9e13
Merge pull request #3070 from water-ghosts/printf-0
printf: Support leading zeroes with %0n formatting
2022-02-05 21:02:16 +01:00
Sylvestre Ledru
252e30c839
Merge pull request #3046 from hbina/hbina-tail-head-dont-use-is-numeric-to-check-digits
tail&head: dont use is_numeric to check for digits
2022-02-05 10:08:01 +01:00
Eli Youngs
162f85773e printf: Support leading zeroes with %0n formatting 2022-02-05 00:43:09 -08:00
Allan Silva
6a6875012e wc: implement files0-from option
When this option is present, the files argument is not processed. This option processes the file list from provided file, splitting them by the ascii NUL (\0) character. When files0-from is '-', the file list is processed from stdin.
2022-02-04 10:12:08 -03:00
Hanif Ariffin
793d3dd97c test_printf: add test for additional escape (\c)
Using this escaped character will cause `printf` to stop generating characters.

For instance,

```rust
hbina@akarin ~/g/uutils (hbina-add-test-for-additional-escape)> cargo run --quiet -- printf "%s\c%s" a b
a⏎
```

Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
2022-02-04 18:47:23 +08:00
Sylvestre Ledru
b4c85b2c17
Merge pull request #2997 from tertsdiepraam/cp-allow-hyphen-suffix
`uucore`: allow backup suffix with hyphen value
2022-02-04 10:29:21 +01:00
Sylvestre Ledru
033fd62f6a
Merge pull request #3047 from hbina/hbina-touch-better-msg-when-no-args
touch: Better error messages when no args is provided
2022-02-04 10:27:01 +01:00
Jeffrey Finkelstein
3fbaa79359 dd: add support for 'b' and 'x' multipliers
Support the suffix 'b' (multiply by 512) and 'x' (multiply by an
arbitrary amount) when specifying numeric arguments to dd.
2022-02-03 21:56:13 -05:00
snobee
f7e31f6008 stat: allow formatting of negative numbers 2022-02-03 16:01:19 -08:00
Hanif Ariffin
e60b581c38
test_sort: Preserve the environment variable when executing tests (#3031)
* test_sort: Output sorted files to a file with different name

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.43262@gmail.com>

* Fix the test by saving the environment variable

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.43262@gmail.com>

Co-authored-by: Hanif Bin Ariffin <hanif.ariffin.43262@gmail.com>
2022-02-03 16:02:50 +01:00
Hanif Bin Ariffin
3586465917 dont use is_numeric to check for digits
Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.43262@gmail.com>
2022-02-03 21:42:22 +08:00
snobee
ee721ebf4e head: handle multibyte numeric utf-8 chars 2022-02-03 21:42:22 +08:00
Hanif Ariffin
9cd65c766a Add tests
Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
2022-02-03 21:14:56 +08:00
Hanif Bin Ariffin
c4c666814b Merge branch 'main' of github.com:uutils/coreutils into hbina-test_ls_order_time-is-flaky 2022-02-03 19:57:13 +08:00
Sylvestre Ledru
2d3b8db9ed
Merge pull request #3012 from shoriminimoe/2951-truncate
truncate: change cli error return code
2022-02-03 10:43:16 +01:00
Eli Youngs
d50c9c3e77 Fail when copying a directory to a file 2022-02-02 23:59:32 -08:00
Sylvestre Ledru
b411d91fac
Merge pull request #3014 from HeroicKatora/main
Make true return false less frequently
2022-02-02 21:43:21 +01:00
Sylvestre Ledru
64f3cd748d
Merge pull request #2976 from danieleades/lint
add additional lints
2022-02-02 09:55:57 +01:00
Eli Youngs
45751e9e48 cp: Create backup before hardlink 2022-02-01 23:49:39 -08:00
Narasimha Prasanna HN
be6287e3e3 Fix: Avoid infinite recursive copies when source and destination directories are same or source is a prefix of destination 2022-02-02 11:17:53 +05:30
Hanif Bin Ariffin
560cd74a63 test_ls: Do not rely on the system time of metadata'access time
Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.43262@gmail.com>
2022-02-02 12:49:40 +08:00
Sam Caldwell
ea5541db56 truncate: add test_invalid_option 2022-02-01 13:42:50 -07:00
Terts Diepraam
87e582b5e0
Merge pull request #2977 from Dr-Emann/echo_octal_nul
echo: Allow echo with escapes to work with `\0`
2022-02-01 20:13:53 +01:00
Andreas Molzer
23a544c485 false,true: Implement custom help, version
This avoids hacking around the short options of these command line
arguments that have been introduced by clap. Additionally, we test and
correctly handle the combination of both version and help. The GNU
binary will ignore both arguments in this case while clap would perform
the first one. A test for this edge case was added.
2022-02-01 14:29:26 +01:00
Andreas Molzer
149399c1bf false,true: Add by-util tests for options 2022-02-01 13:02:18 +01:00
Terts Diepraam
08f1199b08 ls: fix flaky test test_ls_io_errors 2022-02-01 10:55:15 +01:00
Terts Diepraam
7fc82cd376
Merge pull request #2902 from jtracey/join-non-unicode-sep
join: add support for non-unicode field separators
2022-01-31 21:54:56 +01:00
Terts Diepraam
7477761428
Merge pull request #2882 from jtracey/join-bigfields-compat
join: "support" field numbers larger than usize::MAX
2022-01-31 21:52:13 +01:00
Daniel Eades
4f8d1c5fcf add additional lints 2022-01-31 20:40:47 +01:00
Sylvestre Ledru
829e4fcb2c
Merge pull request #2970 from tertsdiepraam/ls-fix-flaky-test
`ls`: fix flaky test
2022-01-31 14:26:40 +01:00
Terts Diepraam
184b65df20 uucore: allow backup suffix with hyphen value 2022-01-31 12:10:57 +01:00
Zachary Dremann
f75466bb31 tests/paste: Add test to avoid trimming extra whitespace 2022-01-30 23:03:11 -05:00
Zachary Dremann
fa44957a63 paste: Handle unicode delimiters 2022-01-30 23:00:49 -05:00
Jeffrey Finkelstein
cba0696b90 head: don't add trailing newline to end of file
Prevent `head` from adding a trailing newline to the end of a file
that did not originally have one when using `head --lines=-0`.
2022-01-30 22:04:19 -05:00
Jeffrey Finkelstein
fe5b537f56 truncate: error when trying to truncate a fifo
Terminate the `truncate` program with an error message when trying to
truncate a named pipe (also known as a fifo).
2022-01-30 22:03:12 -05:00
Justin Tracey
58d65fb953 join: add support for non-unicode field separators
This allows for `-t` to take invalid unicode (but still single-byte) values
on unix-like platforms. Other platforms, which as of the time of this commit
do not support `OsStr::as_bytes()`, could possibly be supported in the future,
but would require design decisions as to what that means.
2022-01-30 20:04:22 -05:00
Terts Diepraam
96d3a95a39 test: fix wsl executable permission 2022-01-31 00:22:21 +01:00
Zachary Dremann
d6a0b3c920 Allow echo with escapes to work with \0
Testing with gecho on macos outputs a nul character for a \0
2022-01-30 17:24:29 -05:00
Terts Diepraam
e01e2141f5 ls: fix flaky test (#2969) 2022-01-30 20:09:20 +01:00
Daniel Eades
ba45fe312a use 'Self' and derive 'Default' where possible 2022-01-30 15:08:26 +01:00
Daniel Eades
2f85610cc3 remove explicit iter loops 2022-01-30 15:08:26 +01:00
Daniel Eades
784f2e2ea1 use semicolons if nothing returned 2022-01-30 15:08:26 +01:00
Daniel Eades
a2d5f06be4 remove needless pass by value 2022-01-30 15:08:26 +01:00
Daniel Eades
f4c6ea0ee8 remove unnecessary 'to_owned' 2022-01-30 14:01:21 +01:00
Daniel Eades
191e29f951 simplify some boolean operations 2022-01-30 14:01:21 +01:00
Daniel Eades
f2074140ec use 'char' instead of 'str' for single character patterns 2022-01-30 14:01:21 +01:00
Daniel Eades
5af66753af remove needless borrows 2022-01-30 14:01:21 +01:00
Sylvestre Ledru
81b2a240e6
Merge pull request #2960 from water-ghosts/fix-cp-a-panic
Don't panic when calling cp -a with a nonexistent file
2022-01-30 11:30:56 +01:00
Sylvestre Ledru
bfa2d8b7da
Merge pull request #2875 from kimono-koans/ls_bad_fd_2
ls: Fix display of bad file descriptor errors
2022-01-30 09:59:58 +01:00
Sylvestre Ledru
7c1abdb7d9
Merge pull request #2866 from jfinkels/split-number-2
split: implement -n option
2022-01-30 09:58:04 +01:00
Sylvestre Ledru
b8b642101f
Merge pull request #2898 from jfinkels/tail-lines-zero-terminated
tail: support zero-terminated lines in streams
2022-01-30 09:44:04 +01:00
Eli Youngs
71c889116e Fix formatting and unused variable checks 2022-01-30 00:33:06 -08:00
Eli Youngs
680e9081fe Don't panic when calling cp -a with a nonexistent file 2022-01-29 22:59:53 -08:00
Terts Diepraam
eb82015b23 all: change macros
- Change the main! proc_macro to a bin! macro_rules macro.
- Reexport uucore_procs from uucore
- Make utils to not import uucore_procs directly
- Remove the `syn` dependency and don't parse proc_macro input (hopefully for faster compile times)
2022-01-29 15:26:32 +01:00
Sylvestre Ledru
1dcd3b2c24
Merge pull request #2943 from jfinkels/truncate-no-such-dir
truncate: better error msg when dir does not exist
2022-01-29 12:25:38 +01:00
Sylvestre Ledru
52ab6325a0
Merge pull request #2881 from jtracey/join-null-field-sep
join: add support for `-t '\0'`
2022-01-29 10:55:04 +01:00
Sylvestre Ledru
24744ca42b
Merge pull request #2911 from jfinkels/dd-seek-stdout
dd: support seek=N when destination is stdout
2022-01-29 10:47:17 +01:00