Commit graph

1660 commits

Author SHA1 Message Date
Sylvestre Ledru
9796e01df6
Revert "split: implement round-robin arg to --number" 2022-03-18 14:45:29 +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
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
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
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