Commit graph

4437 commits

Author SHA1 Message Date
DevSabb
f6cb42ee2d shuf: accept multiple occurances of head-count argument 2022-03-28 10:17:07 -04:00
Daniel Hofstetter
a68d77b8cf df: --output w/o "=" doesn't expect further args
"df --output ." was treated as "df --output=." and hence "." was
interpreted as a column name. With this commit, "." is treated as
an argument on its own.

Fixes #3324
2022-03-28 10:13:54 +02:00
Jeffrey Finkelstein
a1f300e8a7 df: allow multiple occurrences of --output arg
Allow multiple occurrences of the `--output` argument. For example,

    $ df --output=source --output=target | head -n1
    Filesystem                Mounted on
2022-03-27 22:14:16 -04:00
Jeffrey Finkelstein
6f32a1921a df: error on duplicate columns in --output arg
Print a usage error when duplicat column names are specified to the
`--output` command-line argument. For example,

    $ df --output=source,source
    df: option --output: field ‘source’ used more than once
    Try 'df --help' for more information.
2022-03-27 22:02:55 -04:00
Sylvestre Ledru
d5d6bc3050
Merge pull request #3294 from jfinkels/df-file-column
df: implement the File column
2022-03-27 23:41:50 +02:00
Sylvestre Ledru
c932236826
Merge pull request #3317 from sylvestre/ls-quote
ls: Add proper quotes on symlink with --quoting-style=shell-escape
2022-03-27 19:22:18 +02:00
Jeffrey Finkelstein
ab717ce370 df: implement the File column
Implement the "File" column in the `df` output table. Before this
commit, a blank entry appeared in the "File" column for each
row. After this commit, a "-" entry appears when `df` is run with no
positional arguments and the filename appears when run with positional
arguments. For example:

    $ touch a b c && df --output=target,file a b c
    Mounted on File
    /          a
    /          b
    /          c
2022-03-27 13:17:36 -04:00
Jeffrey Finkelstein
b34685f8a5 timeout: return 125 on invalid time interval args
Exit with status 125 (indicating an error in `timeout` itself) when
the timeout duration is invalid or the "kill after" duration is
invalid.
2022-03-27 11:45:51 +02:00
Sylvestre Ledru
c79d146dde ls: add support for --quoting-style=shell-escape b --color=auto 2022-03-27 10:50:00 +02:00
Sylvestre Ledru
bbee22bb1c ls: Add missing quote with --quoting-style=shell-escape
Should fix GNU: tests/ls/symlink-quote.sh
2022-03-27 10:50:00 +02:00
Jeffrey Finkelstein
c43ef8b704 timeout: support long form of --kill-after arg
Add support for the long form of the `--kill-after`
argument. Previously only the short form `-k` was supported.
2022-03-26 20:20:30 -04:00
Sylvestre Ledru
98376d8fd5
Merge pull request #3311 from uutils/mkdir2
mkdir: gnu compat: add support of mkdir -p foo/.
2022-03-27 00:15:05 +01:00
Jeffrey Finkelstein
6a8ce447b7 uucore: no uppercase suffixes in parse_time
Disallow uppercase unit suffixes "S", "M", "H", and "D" in
`uucore::parse_time::from_str()` to match the behavior of GNU `sleep`
and `timeout`.
2022-03-26 10:39:00 -04:00
Sylvestre Ledru
fbb64b9c5c mkdir: gnu compat: add support of mkdir -p foo/. 2022-03-25 21:35:27 +01:00
Jeffrey Finkelstein
f856bfc479 dd: move ConversionMode parsing to parseargs mod.
Move the code for parsing the `ConversionMode` to use up to the
`parseargs` module. This location makes more sense for it because the
conversion mode can be determined entirely from the command-line
arguments at the time of parsing just like the other parameters. Using
an enum for this purpose also eliminates the amount of code we need
later on.
2022-03-25 20:56:38 +01:00
Jeffrey Finkelstein
b98bccf9cc dd: move ConversionMode parsing to dd.rs
Move parsing of the `ConversionMode` outside of
`conv_block_unblock_helper()` and up to the code that calls it.
2022-03-25 20:56:38 +01:00
Jeffrey Finkelstein
bd626df70e dd: replace cascading if/else if with enum match
Replace a cascading `if/else if` chain in `conv_block_unblock_helper()`
with a match statement on a new enum, `ConversionMode`, that enumerates
the various modes in which `dd` can operate.
2022-03-25 20:56:38 +01:00
Pyokyeong Son
8108fb15b6
Merge branch 'uutils:main' into mkdir-fix 2022-03-25 23:03:29 +09:00
Sylvestre Ledru
fe648b2666
Merge pull request #3297 from jfinkels/timeout-invalid-signal
timeout: produce usage error on invalid signal
2022-03-23 21:05:34 +01:00
Kartik Sharma
6b85579498
Merge branch 'uutils:main' into stat-fails-to-read-a-file-redirected-to-stdin 2022-03-23 20:09:42 +05:30
Kartik Sharma
193899f09c Modified code to replace all instances of -
Now all instances of `-` will be replaced with real / canonicalized
path of `/dev/stdin`
2022-03-23 20:05:20 +05:30
Sylvestre Ledru
33c49666c3
nproc: make tests/misc/nproc-override.sh pass by implementing OMP_NUM_THREADS=X,Y,Z (#3296)
+ nproc tests: use assert_eq when comparing the two values

Co-authored-by: jfinkels <jfinkels@users.noreply.github.com>
2022-03-23 12:12:54 +01:00
Jeffrey Finkelstein
760a15aa74 timeout: produce usage error on invalid signal
Produce a usage error on an invalid signal argument. For example,

    $ timeout --signal=invalid 1 sleep 0
    timeout: 'invalid': invalid signal
    Try 'timeout --help' for more information.
2022-03-23 08:39:55 +01:00
Jeffrey Finkelstein
e357d2650c clippy fixes from nightly rust 2022-03-22 21:44:33 -04:00
Terts Diepraam
fc1fa8d1f7
Merge pull request #3027 from shoriminimoe/2986-cp
cp: only allow directory for -t
2022-03-22 23:08:54 +01:00
Sylvestre Ledru
291b889d66
Merge pull request #3256 from chordtoll/iseek-oseek
dd: implement iseek + oseek flags
2022-03-22 20:31:05 +01:00
Sylvestre Ledru
c19a8feb22
Merge pull request #3291 from devnexen/illumos_build_fix
fsext solaris/illumos build fix
2022-03-22 20:07:47 +01:00
Sylvestre Ledru
8044981df0
Merge pull request #3289 from uutils/dependabot/cargo/ouroboros-0.15.0
build(deps): bump ouroboros from 0.14.2 to 0.15.0
2022-03-22 08:08:13 +01:00
Jeffrey Finkelstein
f4af226820 uucore: error on negative interval in parse_time
Return an error when a negative interval is provided as the argument
to `uucore::parse_time::from_str()`, since a `Duration` should only be
non-negative.
2022-03-21 21:11:31 -04:00
David Carlier
d8102503bf fsext solaris/illumos build fix 2022-03-21 23:20:22 +00:00
Terts Diepraam
5eeac5881a
Merge pull request #3285 from sylvestre/ls_aA
ls: when -aA are provided, the order matters
2022-03-21 18:14:13 +01:00
Terts Diepraam
e9a6cf043f
Merge pull request #3286 from sylvestre/nproc-2
nproc: add the full support of OMP_THREAD_LIMIT
2022-03-21 18:11:41 +01:00
dependabot[bot]
2024cc37e6
build(deps): bump ouroboros from 0.14.2 to 0.15.0
Bumps [ouroboros](https://github.com/joshua-maros/ouroboros) from 0.14.2 to 0.15.0.
- [Release notes](https://github.com/joshua-maros/ouroboros/releases)
- [Commits](https://github.com/joshua-maros/ouroboros/compare/0.14.2...0.15.0)

---
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-21 16:50:55 +00:00
Sylvestre Ledru
7963287c6c
Merge pull request #3282 from uutils/dependabot/cargo/libc-0.2.121
build(deps): bump libc from 0.2.113 to 0.2.121
2022-03-21 17:49:11 +01:00
Sylvestre Ledru
4942e519fa nproc: add the full support of OMP_THREAD_LIMIT 2022-03-21 13:46:22 +01:00
Sylvestre Ledru
187bddb6af ls: support multiple -a or -A 2022-03-21 13:32:23 +01:00
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
ce28aa8b8a
Merge pull request #3287 from cakebaker/missing_spaces
sort: add two missing spaces in help texts
2022-03-21 13:14: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
3009c73e9c
ls -aA: Add a comment 2022-03-21 09:13:56 +01:00
Daniel Hofstetter
a1d6a8f17a sort: add two missing spaces in help texts 2022-03-21 09:13:33 +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
dependabot[bot]
34d2d1d05e
build(deps): bump libc from 0.2.113 to 0.2.121
Bumps [libc](https://github.com/rust-lang/libc) from 0.2.113 to 0.2.121.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.113...0.2.121)

---
updated-dependencies:
- dependency-name: libc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-20 18:14:52 +00:00
dependabot[bot]
aea30bd4a7
build(deps): bump ioctl-sys from 0.6.0 to 0.8.0
Bumps [ioctl-sys](https://github.com/jmesmon/ioctl) from 0.6.0 to 0.8.0.
- [Release notes](https://github.com/jmesmon/ioctl/releases)
- [Commits](https://github.com/jmesmon/ioctl/compare/ioctl-sys-0.6.0...ioctl-sys-0.8.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-20 16:46:37 +00: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
979909e371 cp: better error message for target-directory 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
Kartik Sharma
71a6ae1443 Added support to read a filename redirected to stdin
- Canonicalization of `/dev/stdin` which points to stdin file
2022-03-20 17:57:00 +05:30
Terts Diepraam
d90a81fb46 all utils: remove short help flag if another -h flag is present 2022-03-20 11:16:20 +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
Terts Diepraam
32cadbc715 pinky: don't include short flag in help 2022-03-19 23:07:04 +01:00
Sylvestre Ledru
1d17400b80
Merge pull request #3274 from jfinkels/split-elide-empty-files
split: elide all chunks when input file is empty
2022-03-19 22:52:57 +01:00
Sylvestre Ledru
377da0ded4
Merge pull request #3270 from cakebaker/ticket_3251
df: omit reserved filesystem blocks in "Available"
2022-03-19 22:50:33 +01:00
Terts Diepraam
bec00546f1
Merge pull request #3263 from cakebaker/remove_direct_option
df: remove unused "--direct" option
2022-03-19 22:38:05 +01:00
Sylvestre Ledru
f4146da604
Merge pull request #3275 from jfinkels/split-handle-broken-pipe
split: catch and handle broken pipe errors
2022-03-19 21:53:11 +01: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
Jeffrey Finkelstein
6d2eff9c27 split: catch and handle broken pipe errors
Catch `BrokenPipe` errors and silently ignore them so that `split`
terminates successfully on a broken pipe. This matches the behavior of
GNU `split`.
2022-03-19 12:11:03 -04:00
Terts Diepraam
76edba0e1e Merge branch 'unittests-in-ci' of github.com:tertsdiepraam/coreutils into unittests-in-ci 2022-03-19 10:58:59 +01:00
Terts Diepraam
094bb61a63 fxi tests for unittests in dd and hashsum 2022-03-19 10:58:45 +01:00
Sylvestre Ledru
3c88fb460b
Merge branch 'main' into dependabot/cargo/clap-3.1.6 2022-03-19 09:26:05 +01:00
Sylvestre Ledru
01da0171b5
Merge pull request #3272 from jfinkels/uucore-parse-time-overflow
uucore, sleep: use Duration::saturating_mul and saturating_add to avoid overflow
2022-03-19 09:24:03 +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
Daniel Hofstetter
50c6599a32 df: omit reserved filesystem blocks in "Available"
fixes #3251
2022-03-18 20:45:15 +01:00
Daniel Hofstetter
ac8dcb6bd3 df: remove unused "--direct" option 2022-03-18 20:45:09 +01:00
chordtoll
a84202ee00 Combine 4 duplicate seek/skip parsing functions into one 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
Benjamin Bouvier
65f94c9d39 Remove duplicate paste dependency 2022-03-18 20:44:01 +01:00
Sylvestre Ledru
9796e01df6
Revert "split: implement round-robin arg to --number" 2022-03-18 14:45:29 +01:00
Terts Diepraam
04de1251dd
Merge branch 'main' into dependabot/cargo/clap-3.1.6 2022-03-18 09:54:04 +01:00
Benjamin Bouvier
ba5b2dc2ed
Remove unused dependencies by individual crates (#3264) 2022-03-17 22:48:17 +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
dependabot[bot]
59440d35c0
build(deps): bump clap from 3.0.10 to 3.1.6
Bumps [clap](https://github.com/clap-rs/clap) from 3.0.10 to 3.1.6.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v3.0.10...v3.1.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-17 13:06:29 +00: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
Sylvestre Ledru
7e05833b96
Merge pull request #3205 from jfinkels/split-round-robin
split: implement round-robin arg to --number
2022-03-16 12:35:00 +01:00
Sylvestre Ledru
161db4cdd7
Merge pull request #3259 from jfinkels/df-loops
df: separate functions for two main modes of df
2022-03-16 12:00:36 +01:00
Sylvestre Ledru
b84ff35766
Add canonicalized to the ignore spell list 2022-03-16 09:16:01 +01:00
Devin Gunay
b277aa235a use powi instead of unnecessary powf
clippy::suboptimal_flops found a few unnecessary usages of powf (powi is faster)
2022-03-16 00:37:29 -07:00
Jeffrey Finkelstein
f4ca963dca df: separate functions for two main modes of df
Split the code for getting a list of `Filesystem` objects into two
separate functions: one for getting the list of all filesystems (when
running `df` with no arguments) and one for getting only named
filesystems (when running `df` with one or more arguments). This does
not change the behavior of `df` only the organization of the code.
2022-03-15 22:06:55 -04:00
Jeffrey Finkelstein
6f3dcf5998 df: add Filesystem::from_path() function
Add the `Filesystem::from_path()` function which produces the
filesystem on which a given path is mounted. The `Filesystem` is taken
from a list of candidate `MountInfo` objects.
2022-03-15 21:56:39 -04:00
Jeffrey Finkelstein
6371eb8298 df: use for loop over filesystems to display rows
Replace a loop over `Row` objects with a loop over `Filesystem`
objects when it comes time to display each row of the output
table. This helps with code structure, since the `Filesystem` is the
primary object of interest in the `df` program. This makes it easier
for us to independently vary how the list of filesystems is produced
and how the list of filesystems is displayed.
2022-03-15 19:43:28 -04: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
8f97283cf3
Merge pull request #3253 from jfinkels/df-filesystem-module-3
df: move Filesystem to filesystem.rs
2022-03-14 09:59:28 +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
Jeffrey Finkelstein
b81f4ef6a7 df: add documentation comments for filesystem.rs 2022-03-13 14:30:15 -04:00
Jeffrey Finkelstein
2fac674317 df: move Filesystem to filesystem.rs
Move the `Filesystem` struct into a new module `filesystem.rs`.
2022-03-13 14:30:14 -04:00
Sylvestre Ledru
24b4af768c nproc: Improve the support of OMP_NUM_THREADS 2022-03-13 18:33:16 +01:00
Sylvestre Ledru
d6dad9f412
Merge pull request #3250 from jfinkels/df-remove-fs-selector
df: remove use of FsSelector abstraction
2022-03-13 18:17:49 +01:00
Jeffrey Finkelstein
81e2de498a df: remove use of FsSelector abstraction
Remove the use of the `FsSelector` struct when deciding whether a
filesystem type should be included or excluded from the output
table. Instead, just maintain optional `Vec`s of filesystem types to
exclude and include, and check whether the filesystem type is
contained in one of those. This reduces the amount of code required to
implement these checks, and since the number of types given in the
`include` or `exclude` lists is likely to be small, there should not
be much of a difference in performance.
2022-03-12 20:52:40 -05: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
Jeffrey Finkelstein
2d390233fe timeout: add ExitStatus enumeration
Add the `ExitStatus` enumeration in a new module `status.rs` to
contain all the magic numbers in the `timeout` utility.
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
OHNONOTAMOTH
094198b22a
Consistent tempfile crate declaration (version 3) (#3244) 2022-03-12 09:40:23 +01:00
Sylvestre Ledru
2c10ddf3f4
Merge pull request #3243 from jfinkels/timeout-restructure
timeout: refactor helper func for wait-then-signal
2022-03-12 09:38:05 +01:00
Jeffrey Finkelstein
9fae445ca9 df: fix tests of internal helper functions
Fix unit tests for the `is_included()` and `filter_mount_list()`
internal helper functions. The function signatures changed but the
tests did not get updated to match.
2022-03-11 22:52:17 -05:00
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
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
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
Justin Tracey
644c99ed2e pinky: simplify and debug printing files 2022-03-07 12:32:07 -05:00
Justin Tracey
9430a9f355 pinky: fix off-by-one in GECOS parsing 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
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
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
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
Terts Diepraam
722c5d268f fix Rust 1.59 clippy lints 2022-02-25 09:39:48 +01:00
ndd7xv
172be3a8c6 install: better error messages when invalid arguments
executing `install` or `install file` no longer panics and insteads returns errors similar to GNU's install when it encounters similar args
2022-02-24 17:58:32 -05:00
Jeffrey Finkelstein
9f71b7ac7f df: correct links in BlockSize documentation 2022-02-23 21:08:35 -05:00
Sylvestre Ledru
d3ca49128d
Merge pull request #3179 from omertuc/test_u64
Improve coverage / error messages from `parse_size` PR
2022-02-23 18:27:14 +01:00
Jeffrey Finkelstein
fc8e9f20ea df: correctly scale bytes by block size
Change `df` so that it correctly scales numbers of bytes by the
default block size, 1024, when neither -h nor -H are specified on the
command-line. Previously, it was not scaling the number of bytes in
this case.

Fixes #3058.
2022-02-22 22:51:26 -05: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
Jeffrey Finkelstein
92d461247e split: extend Strategy::Number to add NumberType
Make the `Strategy::Number` enumeration value more general by
replacing the number parameter with a `NumberType` enum parameter.
This allows a future commit to update `split` to support the various
sub-strategies for the `-n`. (This commit does not add support for the
other sub-strategies.)
2022-02-22 18:41:29 -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
Sylvestre Ledru
2a333ab391
Merge pull request #3084 from omertuc/u64
Fix `parse_size` to use u64 rather than usize for better 32-bit support
2022-02-22 20:47:38 +01:00
Omer Tuchfeld
e9adf979d9 Fix type-error when calling parse_size from stdbuf 2022-02-22 13:49:20 +01:00
Omer Tuchfeld
468ff8f0b9 Fix type-error when calling parse_size from od 2022-02-22 13:49:20 +01:00
Gilad Naaman
6856c5dba5 Fix type-error when calling parse_size from truncate 2022-02-22 13:49:20 +01:00
Gilad Naaman
159a1dc1db Fix type-error when calling parse_size from split 2022-02-22 13:49:20 +01:00
Gilad Naaman
8535cd41e0 Fix type-error when calling parse_size from sort 2022-02-22 13:49:20 +01:00
Omer Tuchfeld
5d861df961 Fix type-error when calling parse_size from tail 2022-02-22 13:49:20 +01:00
Omer Tuchfeld
8d8e25880e Fix type-error when calling parse_size from head 2022-02-22 13:49:20 +01:00
Omer Tuchfeld
0fe6017006 Fix type-error when calling parse_size from du 2022-02-22 13:49:20 +01:00
Omer Tuchfeld
88dfb8d374 Fix type-error when calling parse_size from dd 2022-02-22 13:49:15 +01:00
Omer Tuchfeld
b6c952c46e Fix parse_size to use u64 rather than usize for better 32-bit support
Using usize limits 32-bit platforms to operate only on sizes of 4GiB
or less. While 32-bit platforms only have 4GiB of addressable memory,
not all operations require the data to be entirely in memory, so this
limitation can be lifted if we use u64 instead of usize.

This only fixes the core function, further commits fix the utilities
making use of this function.
2022-02-22 11:09:40 +01:00
Alex Tibbles
163472ff7b
hashsum: pass spell checker 2022-02-21 20:43:42 -05:00
Alex Tibbles
3a0f292510
hashsum: refactor macro name 2022-02-21 17:04:57 -05:00
Alex Tibbles
afd5fea3c8
hashsum: refactor MD5 to use macro 2022-02-21 17:00:34 -05:00
Alex Tibbles
b1c543b4d2
hashsum: re-factor SHA1 implementation into common macro 2022-02-21 16:58:20 -05:00
Alex Tibbles
00d3c36e8c
update SHA1, SHA2, SHA3 crates 2022-02-21 16:55:59 -05:00
Alex Tibbles
41e9719d6b
upgrade to RustCrypto Hashes MD5 "MD-5" 0.10.1 2022-02-21 16:51:00 -05:00
Alex Tibbles
c8346fd720
hashsum: update hex to 0.4.3
Update to API change.
2022-02-21 15:35:46 -05:00
Sylvestre Ledru
6c7decc42b
Merge pull request #3172 from alextibbles/update-strum
uniq: update strum to 0.23 latest
2022-02-21 19:28:55 +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
Alex Tibbles
0d5dd27e71
uniq: update strum to 0.23 latest 2022-02-21 12:34:25 -05:00
Terts Diepraam
53070141c1
all: add format_usage function (#3139)
This should correct the usage strings in both the `--help` and user documentation. Previously, sometimes the name of the utils did not show up correctly.
2022-02-21 17:14:03 +01:00
alextibbles
cd450cc591
expr: update onig crate to 6.3 (#3136)
* expr: update onig crate to 6.3
2022-02-21 17:13:27 +01: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
Jeffrey Finkelstein
1076fbd492 dd: move block-related functions into new module
Create a new module `blocks.rs` to contain the block-related helper
functions. This commit only moves the location of the code and related
tests, it does not change the functionality of `dd`.
2022-02-20 22:16:54 -05:00
Terts Diepraam
938c5acbbe
Merge pull request #3146 from ndd7xv/split-suffix-check
split: error when num. of chunks is greater than num. of possible filenames
2022-02-20 17:12:05 +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
b09bae2acf dd: collect progress reporting into its own module
Collect structs, implementations, and functions that have to do with
reporting number of blocks read and written into their own new module,
`progress.rs`. This commit also adds docstrings for everything and
unit tests for the significant methods. This commit does not change
the behavior of `dd`, just the organization of the code to make it
more maintainable and testable.
2022-02-19 10:39:40 -05:00