Commit graph

4172 commits

Author SHA1 Message Date
Jeffrey Finkelstein
a0eed2405c timeout: refactor helper func for wait-then-signal
Factor a helper function `wait_or_kill_process()` out of the main
`timeout()` function. This helper function contains the code to wait
for a child process and send the `SIGKILL` signal if it does not
terminate within a specified amount of time. This does not change the
function of `timeout`, just the organization of the code.
2022-03-11 18:47:30 -05: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
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
0b07ecdad2 df: use Options.columns field to control output
Replace the `Options.show_fs_type` and `Options.show_inode_instead`
fields with the more general `Options.columns`, a `Vec` of `Column`
variants representing the exact sequence of columns to display in the
output. This makes `Options` able to represent arbitrary output column
display configurations.
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
2e8945ba7f
Merge pull request #3221 from uutils/dependabot/cargo/unicode-segmentation-1.9.0
build(deps): bump unicode-segmentation from 1.8.0 to 1.9.0
2022-03-10 00:32:13 +01:00
Sylvestre Ledru
3b78023fcb
Merge pull request #3220 from uutils/dependabot/cargo/strum-0.24.0
build(deps): bump strum from 0.23.0 to 0.24.0
2022-03-10 00:30:29 +01: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
dependabot[bot]
fc4f1d869e build(deps): bump strum from 0.23.0 to 0.24.0
Bumps [strum](https://github.com/Peternator7/strum) from 0.23.0 to 0.24.0.
- [Release notes](https://github.com/Peternator7/strum/releases)
- [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Peternator7/strum/commits)

---
updated-dependencies:
- dependency-name: strum
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-09 19:45:40 +01:00
dependabot[bot]
b4ee7f84fa build(deps): bump unicode-segmentation from 1.8.0 to 1.9.0
Bumps [unicode-segmentation](https://github.com/unicode-rs/unicode-segmentation) from 1.8.0 to 1.9.0.
- [Release notes](https://github.com/unicode-rs/unicode-segmentation/releases)
- [Commits](https://github.com/unicode-rs/unicode-segmentation/commits)

---
updated-dependencies:
- dependency-name: unicode-segmentation
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-09 19:45:35 +01:00
Daniel Hofstetter
3317fb9924 df: always round up usage percentage (#3208) 2022-03-08 15:13:05 +01: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
Sylvestre Ledru
858a38c815
Merge pull request #3222 from uutils/dependabot/cargo/once_cell-1.10.0
build(deps): bump once_cell from 1.9.0 to 1.10.0
2022-03-07 07:04:15 +01:00
Nick Donald
a74ffac19e printf: fix printf sci notation round up 2022-03-07 07:01:21 +01:00
dependabot[bot]
1c469ec6c5
build(deps): bump ouroboros from 0.10.1 to 0.14.2
Bumps [ouroboros](https://github.com/joshua-maros/ouroboros) from 0.10.1 to 0.14.2.
- [Release notes](https://github.com/joshua-maros/ouroboros/releases)
- [Commits](https://github.com/joshua-maros/ouroboros/commits/0.14.2)

---
updated-dependencies:
- dependency-name: ouroboros
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-06 22:36:00 +00:00
dependabot[bot]
2e50eade7f
build(deps): bump once_cell from 1.9.0 to 1.10.0
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.9.0 to 1.10.0.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.9.0...v1.10.0)

---
updated-dependencies:
- dependency-name: once_cell
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-06 22:35:33 +00:00
Sylvestre Ledru
9113594951
Merge pull request #3206 from 353fc443/timeout-empty-string
timeout: avoid panicking for empty string
2022-03-06 23:02:46 +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
Sylvestre Ledru
54a10e955a Update of the cargo.lock url to point to the right branch 2022-03-06 22:13:17 +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
281ec190e0
chmod: replace walkdir with std::fs
walkdir filters some files that need to be modified, for example, files inside an unreadable folder.
2022-03-06 08:40:36 +08:00
Davide Cavalca
19af43222b Include license text in all published crates 2022-03-05 21:21:46 +01: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
Jeffrey Finkelstein
14e3f50651 df: move BlockSize to a new module, blocks.rs 2022-03-05 11:36:16 -05:00
353fc443
6951e18c41 timeout: avoid panicking for empty string 2022-03-05 14:36:24 +01: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
Jeffrey Finkelstein
41acdb5471 df: borrow Row in DisplayRow::new()
Change the signature of `DisplayRow::new()` to borrow `Row` instead of
consuming it, so that the `Row` can be used after it is displayed.
2022-03-05 10:29:46 +01:00
Jeffrey Finkelstein
3fb36d02e3 df: add unit tests for internal helper functions
Add unit tests in the `df.rs` file for internal helper functions
`mount_info_lt()`, `is_best()`, `is_included()`, and
`filter_mount_list()`.
2022-03-05 10:28:37 +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
Terts Diepraam
75b3cbcfd9 pr: move from getopts to clap
fixes
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
1c023c6523
Merge pull request #3202 from cakebaker/patch-1
cp: fix typo in help text
2022-03-01 10:14:06 +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
Daniel Hofstetter
5cce2b0d9a
cp: fix typo in help text 2022-02-28 15:16:47 +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
Jeffrey Finkelstein
7273d1f100 df: use safe wrapper function for statfs() func.
Replace unsafe code with a safe version of the `statfs()` function
provided by `uucore`.
2022-02-27 17:33:01 -05: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
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