Commit graph

2761 commits

Author SHA1 Message Date
Pyokyeong Son
65a45ae5e1 Merge branch 'main' of github.com:pyoky/coreutils 2022-02-17 08:22:27 +00:00
Pyokyeong Son
ea175ce252 mkdir: permissions respects umask
- hardcoded default permissions changed to ones defined by umask
2022-02-17 07:37:55 +00:00
ndd7xv
494d709e0f split: small tweaks to wording
changes `SuffixType` enums to have better names and hex suffix help to be consistent with numeric suffix help
2022-02-17 01:04:26 -05:00
xxyzz
c16c06ea0d
df: add output option's valid field names 2022-02-17 13:43:59 +08:00
ndd7xv
6c3fc7b214 split: throw error when # chunks > # filenames from suffix length 2022-02-16 23:53:56 -05:00
Jeffrey Finkelstein
4470430c89 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-16 23:53:56 -05:00
Jeffrey Finkelstein
891c5d1ffa split: add SuffixType::NumericHexadecimal
Add a `NumericHexadecimal` member to the `SuffixType` enum so that a
future commit can add support for hexadecimal filename suffixes to the
`split` program.
2022-02-16 23:53:56 -05:00
Jeffrey Finkelstein
aa4c5aea50 split: refactor to add SuffixType enum
Refactor the code to use a `SuffixType` enumeration with two members,
`Alphabetic` and `NumericDecimal`, representing the two currently
supported ways of producing filename suffixes. This prepares the code
to more easily support other formats, like numeric hexadecimal.
2022-02-16 23:53:56 -05:00
Terts Diepraam
9e847c33e3
Merge pull request #3021 from iovanom/dd-multi-status-options
dd: allow multiple instances of arguments
2022-02-16 12:56:30 +01: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
Michael Lohmann
3bbfe00791 cat: write_nonprint_to_end: be more explicit about printing '?' 2022-02-15 22:27:46 +01:00
Michael Lohmann
4676924532 cat: cat_path does not need to parse InputType for stdin itself
This type is already handled by get_input_type, so we can unify the handling
2022-02-15 22:27:46 +01:00
Michael Lohmann
34b18351e2 cat: cleanup write_tab_to_end duplication of logic
The logic for '\n' and '\r' about the number of written characters was duplicated
2022-02-15 22:16:02 +01:00
Sylvestre Ledru
65467ab317
Merge pull request #3137 from tertsdiepraam/docs-multiline-usage
docs: allow for multiline usage
2022-02-15 10:26:47 +01: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
xxyzz
c849b8722f
df: --output option conflicts with -i, -P, -T 2022-02-14 09:10:54 +08:00
xxyzz
e77c8ff381
df: -t may appear more than once and doesn't support delimiter 2022-02-14 09:09:35 +08:00
Terts Diepraam
477b40f1e5 shuf: correct execution phrase for --help 2022-02-13 21:58:48 +01:00
Kartik Sharma
6c1a655512
This commit removes empty line from USAGE string in src/uu/od/src/od.rs. (#3074)
This change is needed to fix missing USAGE section for `od` in user docs.

With reference to this issue
https://github.com/uutils/coreutils/issues/2991, and missing USAGE
section from `od docs` at
https://uutils.github.io/coreutils-docs/user/utils/od.html, it was
found that the USAGE for od app was starts with an empty line and uudoc
only takes 1st line for using in USAGE section in docs.
This resulted in empty line in usage section for `od`
2022-02-13 21:39:11 +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
Jeffrey Finkelstein
494dc7ec57 split: add SuffixType::NumericHexadecimal
Add a `NumericHexadecimal` member to the `SuffixType` enum so that a
future commit can add support for hexadecimal filename suffixes to the
`split` program.
2022-02-13 11:18:37 -05:00
Jeffrey Finkelstein
7fbd805713 split: refactor to add SuffixType enum
Refactor the code to use a `SuffixType` enumeration with two members,
`Alphabetic` and `NumericDecimal`, representing the two currently
supported ways of producing filename suffixes. This prepares the code
to more easily support other formats, like numeric hexadecimal.
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
Jeffrey Finkelstein
042e537ca8 df: refactor is_included(), mount_info_lt() funcs
Factor two helper functions, `is_included()` and `mount_info_lt()`,
from the `filter_mount_list()` function.
2022-02-12 21:06:37 -05:00
Jeffrey Finkelstein
b13718e742 head: use Self instead of enum name Mode in method 2022-02-12 14:45:45 -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
0f17ef2028
Merge pull request #2906 from jfinkels/head-better-mode
head: incorporate "all but last" option into Mode
2022-02-12 19:01:49 +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
Sylvestre Ledru
c67a64c9df
Merge pull request #3121 from serhansekman/pr-help-page
pr: add missing about and version to documentation
2022-02-12 18:13:31 +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
Hanif Ariffin
45a1b7e4bb
ls: refactor out padding calculations (#3072)
* Refactor padding calculations into a function

* Propagate all write and (most) flush errors
2022-02-12 11:39:17 +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
52282740dd
Merge pull request #3078 from ndd7xv/dd-progress-fix
dd: make status=progress rewrite once/sec
2022-02-12 11:34:21 +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
e76818bb19
Merge pull request #3083 from jfinkels/df-table-module
df: refactor data table into Row, Header structs
2022-02-12 11:30:28 +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
Tevfik Serhan Sekman
ad1954bd16 pr: add missing about and version to documentation 2022-02-12 12:36:28 +03:00
Pat Laster
aacff13ec3 seq: Eliminated special handling of -0.0 2022-02-11 23:02:57 -06: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
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
Ivan Majeru
c3b4d898ee dd: allow multiple occurences for iflag, oflag and conv
The iflag, oflag and conv cli arguments take a list of values
and the correct behavior is to collect all values from multiple
occurences of theme.

For example if we call `dd --iflag=directory --iflag=skip_bytes` this should
collect the two values, `directory` and `skip_bytes` for iflag.

The unittest was added for this case.
2022-02-10 18:34:27 +02:00
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
Hanif Ariffin
4006524798 Merge branch 'main' of github.com:uutils/coreutils into hbina-ls-propagate-write-errors 2022-02-09 16:10:28 +08:00
Sylvestre Ledru
e5be9c1aaf
Merge pull request #3099 from tertsdiepraam/shuf-refactor
`shuf`: remove custom logic for bounded randomization
2022-02-09 07:37:22 +01:00
Jeffrey Finkelstein
b37718de10 split: add BENCHMARKING.md documentation file 2022-02-08 22:58:00 -05:00
Jeffrey Finkelstein
70ca1f45ea split: remove unused ByteSplitter and LineSplitter 2022-02-08 22:58:00 -05:00
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
b31d63eaa9 split: add ByteChunkWriter and LineChunkWriter
Add the `ByteChunkWriter` and `LineChunkWriter` structs and
implementations, but don't use them yet. This structs offer an
alternative approach to writing chunks of output (contrasted with
`ByteSplitter` and `LineSplitter`). The main difference is that
control of which underlying file is being written is inside the writer
instead of outside.
2022-02-08 22:53:56 -05:00
Terts Diepraam
dc24c9563e shuf: BENCHMARKING.md 2022-02-08 21:05:39 +01: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
12d5139320
Merge pull request #3095 from jfinkels/dd-concise-main-loop
dd: make main loop more concise
2022-02-08 20:44:39 +01:00
Terts Diepraam
9538814702 shuf: use split_once for parsing the range 2022-02-08 14:39:32 +01:00
Terts Diepraam
30ae952b83 shuf: remove custom randomization logic 2022-02-08 14:39:32 +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
Narasimha Prasanna HN
0379fca260 Fix merge conflict in tests/by-util/test_cp.rs 2022-02-07 23:26:06 +05:30
Jeffrey Finkelstein
c002b16c67 dd: make main loop more concise
Add some helper functions and adjust some error-handling to make the
`Output::dd_out()` method, containing the main loop of the `dd`
program, more concise. This commit also adds documentation and
comments describing the main loop procedure in more detail.
2022-02-07 10:00:49 -05:00
Allan Silva
e6c94c1cd7 wc: Fix clippy error 2022-02-07 10:20:52 -03:00
Sylvestre Ledru
b14e396983
Merge pull request #3091 from jfinkels/df-flatten-filter-mount-list
df: refactor filter_mount_list() to be more flat
2022-02-07 10:59:23 +01:00
Justin Tracey
41c90d79c4 join: add benchmarking documentation 2022-02-06 23:53:03 -05:00
Justin Tracey
ac9d006886 join: guess the number of fields in each line
This lets us use fewer reallocations when parsing each line.
The current guess is set to the maximum fields in a line so far. This is
a free performance win in the common case where each line has the same
number of fields, but comes with some memory overhead in the case where
there is a line with lots of fields at the beginning of the file, and
fewer later, but each of these lines are typically not kept for very
long anyway.
2022-02-06 23:37:17 -05:00
Justin Tracey
f33e058a5a join: faster field parsing and representation
Using indexes into the line instead of Vec<u8>s means we don't have to copy
the line to store the fields (indexes instead of slices because it avoids
self-referential structs). Using memchr also empirically saves a lot of
intermediate allocations.
2022-02-06 23:37:17 -05:00
Justin Tracey
e6f59b12f7 join: lock and buffer stdout
By abstracting the writer we write to, we can lock stdout once at the
beginning, then use buffered writes to it throughout.
2022-02-06 23:37:17 -05:00
Justin Tracey
c12f393150 join: improve error handling 2022-02-06 23:37:06 -05:00
Jeffrey Finkelstein
9528d514bf df: refactor data table into Row, Header structs
Refactor the code for representing the `df` data table into `Header`
and `Row` structs. These structs live in a new module `table.rs`. When
combined with the `Options` struct, these structs can be
`Display`ed. Organizing the code this way makes it possible to test
the display settings independently of the machinery for getting the
filesystem data. New unit tests have been added to `table.rs` to
demonstrate this benefit.
2022-02-06 21:54:58 -05:00
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
84d4f24b8c dd: avoid infinite loop in Input::force_fill()
Avoid an infinite loop in `Input::force_fill()` when the input has
fewer bytes than are being requested to be read from the input.
2022-02-06 20:10:41 -05:00
Jeffrey Finkelstein
8fa6797255 split: add structure to errors that can be created
Add some structure to errors that can be created during parsing of
settings from command-line options. This commit creates
`StrategyError` and `SettingsError` enumerations to represent the
various parsing and other errors that can arise when transforming
`ArgMatches` into `Settings`.
2022-02-06 20:09:29 -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
572b2e032c df: refactor filter_mount_list() to be more flat
Use a `for` loop in the `filter_mount_list()` function to make the
filtering logic easier to read.
2022-02-06 20:04:03 -05:00
ndd7xv
3842ecb1b4 dd: status=progress rewrites once/sec 2022-02-06 17:56:08 -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
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
Sylvestre Ledru
57cf3a533f
Merge pull request #3067 from ndd7xv/printf-clap-defaults
printf: use clap default help and version
2022-02-05 22:16:44 +01: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
Hanif Ariffin
78847e2ad0 Undo a small change that was meant to silence clippy
Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
2022-02-05 23:40:23 +08:00
Hanif Ariffin
519e82240a Revert "Refactor padding calculations into a function"
This reverts commit f39b861469.

Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
2022-02-05 23:32:44 +08:00
Sylvestre Ledru
ebf33d775e
Merge pull request #3023 from RishiKumarRay/main
basenc, base64 and base32 have an ABOUT that's formatted differently than the other utils
2022-02-05 14:40:03 +01:00
Hanif Ariffin
e35b93156a Propagate all write and (most) flush errors
Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
2022-02-05 19:30:39 +08:00
Hanif Ariffin
f39b861469 Refactor padding calculations into a function
Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
2022-02-05 19:12:05 +08: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
ndd7xv
5e790918ef printf: use clap default help and version 2022-02-04 22:07:31 -05: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
Sylvestre Ledru
572a505119
Merge pull request #3024 from ndd7xv/printf-version-documentation
printf: add description and version
2022-02-04 10:45:28 +01:00
Guilherme Augusto de Souza
ae755bb9bd
test: add version and about (#3011) 2022-02-04 10:28:15 +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
639971e520 df: refactor function for parsing CLI args
Add a `Options::from()` function to collect the code for parsing an
`Options` object from the `clap::ArgMatches` object.
2022-02-03 23:19:14 -05: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
861437addf Fix small clippy issue
Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
2022-02-03 21:45:02 +08: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
ff8a83b256 touch: Better error message when no args is given
Matches the behavior of GNU touch

```shell
hbina@akarin ~/g/uutils (hbina-realpath-absolute-symlinks)> touch > /dev/null
touch: missing file operand
Try 'touch --help' for more information.
hbina@akarin ~/g/uutils (hbina-realpath-absolute-symlinks) [1]> cargo run --quiet -- touch > /dev/null
touch: missing file operand
Try 'touch --help' for more information.
hbina@akarin ~/g/uutils (hbina-realpath-absolute-symlinks) [1]> cargo run --quiet -- touch 2> /dev/null
hbina@akarin ~/g/uutils (hbina-realpath-absolute-symlinks) [1]> touch 2> /dev/null
```

Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
2022-02-03 21:10:39 +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
DevSaab
773ceb5534 Include ABOUT for shuf 2022-02-02 10:08:48 -05:00
Sylvestre Ledru
57231e6543
Merge pull request #3030 from rahulkadukar/hostid-description
hostid: added description in documentation
2022-02-02 10:29:26 +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
Ivan Majeru
9c73926616 Merge branch 'main' into dd-multi-status-options 2022-02-02 09:08:37 +02: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
Rahul Kadukar
7e32b6ba17
Added description for hostid 2022-02-01 23:51:48 -05:00
Nathan
29b613a852 printf: resolve formatting nit in LONGHELP strings
Removed 1 preceeding space for LONGHELP_LEAD and 2 preceeding spaces for LONGHELP_BODY
2022-02-01 22:36:10 -05:00
Nathan
f6174dd946 printf: add description and version
Adds a version number and brief description to the printf utility in the user documentation
2022-02-01 19:28:39 -05:00
Sam Caldwell
39f8329222 truncate: use map_err instead of unwrap_or_else 2022-02-01 14:13:52 -07:00
Rishi Kumar Ray
f117fd8dd6 added correct format to ABOUT 2022-02-02 02:40:59 +05:30
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
c6d5eccf6c false,true: Resolve formatting nit in About 2022-02-01 19:53:25 +01:00
Ivan Majeru
19cc63df9a dd: allow multiple instances of arguments
Correct the behavior of `dd` when multiple arguments are provided.
Before this commit, if the multiple arguments was provided then
the validation error are returned.

For example

```
$ printf '' | ./target/debug/dd status=none status=noxfer
error: The argument '--status=<LEVEL>' was provided more than once, but cannot be used multiple times

USAGE:
    dd [OPTIONS]

For more information try --help
```

The unittest was added for this case.
2022-02-01 20:32:56 +02: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
c1e108933f false,true: Align behavior of short flags to GNU 2022-02-01 13:02:22 +01:00
Andreas Molzer
dcf177f908 false: Align behavior to true and GNU 2022-02-01 12:04:23 +01:00
Andreas Molzer
b29e219e4d true: Rework to return true more often
Now treats recognized command line options and ignores unrecognized
command line options instead of returning a special exit status for
them.

There is one point of interest, which is related to an implementation
detail in GNU `true`. It may return a non-true exit status (in
particular EXIT_FAIL) if writing the diagnostics of a GNU specific
option fails. For example `true --version > /dev/full` would fail and
have exit status 1.

	This behavior was acknowledged in gnu in commit
	<9a6a486e6503520fd2581f2d3356b7149f1b225d>. No further
	justification provided for keeping this quirk.

POSIX knows no such options, and requires an exit status of 0 in all
cases. We replicate GNU here which is a consistency improvement over the
prior implementation. Adds documentation to clarify the intended
behavior more properly.
2022-02-01 09:13:00 +01:00
Sam Caldwell
e1f7c774d8 Remove redundant import 2022-01-31 22:59:10 -07:00
Sam Caldwell
6f24166c63 [truncate] handle unused_must_use warning 2022-01-31 22:25:59 -07:00
Sam Caldwell
cd1b5c5748 [truncate] change cli error return code
Exit with status code 1 for argument parsing errors in `truncate`. When
`clap` encounters an error during argument parsing, it exits with status
code 2. This causes some GNU tests to fail since they expect status code
1.
2022-01-31 22:08:59 -07:00
Narasimha Prasanna HN
1194a8ce53
Fix: Update quick-error crate version from 1.2.3 to 2.0.1 in src/uu/cp (#2947)
fix: update quick-error crate from 1.2.3 to 2.0.1 for src/uu/cp tool, fixes:  #2941
2022-01-31 21:56:47 +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
dfc661e8b5
Merge pull request #2975 from douglaz/sha_update
Updated sha libraries
2022-01-31 08:26:49 +01:00
Zachary Dremann
ad4c5d3357 paste: Use a single buffer 2022-01-30 23:01:15 -05:00
Zachary Dremann
85a81d328a paste: Create vec with capacity 2022-01-30 23:01:11 -05:00
Zachary Dremann
ff14f25c34 paste: Reuse output allocation 2022-01-30 23:01:05 -05:00
Zachary Dremann
8905d52279 paste: Write to a locked stdout 2022-01-30 23:01:01 -05:00
Zachary Dremann
c6ec4f8f17 paste: Store delimiters as chars, rather than strings 2022-01-30 23:00:56 -05:00
Zachary Dremann
fa44957a63 paste: Handle unicode delimiters 2022-01-30 23:00:49 -05:00
Jeffrey Finkelstein
b9c2066ee9 uucore: move lines.rs to be a uucore feature
Refactor the `lines.rs` module to be a feature in `uucore`. It was
common to both `head` and `tail`.
2022-01-30 22:15:35 -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
371278e043 truncate: fix typo in docs: "the any" -> "any" 2022-01-30 22:03:13 -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
Jeffrey Finkelstein
83eac9c0a8 head: incorporate "all but last" option into Mode
Refactor the `Mode` enum in the `head.rs` module so that it includes
not only the mode type---lines or bytes---but also whether to read the
first NUM items of that type or all but the last NUM. Before this
commit, these two pieces of information were stored separately. This
made it difficult to read the code through several function calls and
understand at a glance which strategy was being employed.
2022-01-30 22:01:25 -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
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
7b3cfcf708
Merge pull request #2868 from jfinkels/split-filename-iterator
split: use iterator to produce filenames
2022-01-30 22:37:37 +01:00
Allan Douglas R. de Oliveira
f22051a4e1 Updated sha libraries 2022-01-30 17:23:02 -03:00
Daniel Eades
41e2197188 squash some repeated match blocks 2022-01-30 18:32:09 +01:00
Sylvestre Ledru
de07df5992
Merge pull request #2963 from danieleades/refactor/code-quality
Refactor/code quality
2022-01-30 18:26:16 +01:00
Jeffrey Finkelstein
a5b435da58 split: use iterator to produce filenames
Replace the `FilenameFactory` with `FilenameIterator` and calls to
`FilenameFactory::make()` with calls to `FilenameIterator::next()`. We
did not need the fully generality of being able to produce the
filename for an arbitrary chunk index. Instead we need only iterate
over filenames one after another. This allows for a less
mathematically dense algorithm that is easier to understand and
maintain. Furthermore, it can be connected to some familiar concepts
from the representation of numbers as a sequence of digits.

This does not change the behavior of the `split` program, just the
implementation of how filenames are produced.

Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
2022-01-30 11:18:58 -05: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
cf24620d3d remove 'let and return' 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
8bb6c4effa use pointer args 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
2f6f6867c5
Merge branch 'main' into 2940 2022-01-30 13:33:35 +01:00
Sylvestre Ledru
57dc11e586
Merge pull request #2871 from jfinkels/split-settings-methods
split: add a method to convert ArgMatches to Settings
2022-01-30 11:31:58 +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
680e9081fe Don't panic when calling cp -a with a nonexistent file 2022-01-29 22:59:53 -08:00
Dan Klose
bb7f37e8b4 fix: update itertools 0.8.0 -> 0.10.0
Targets https://github.com/uutils/coreutils/issues/2940

* since versions were mxing versions of x.y and x.y.z I changed all to x.y.z
* minor whitespace formatting
2022-01-29 22:35:51 +00: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
196a7a921c
Merge pull request #2877 from jfinkels/head-use-uucore-error-handling
head: use uucore error handling instead of custom
2022-01-29 10:53:48 +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
Sylvestre Ledru
57ee6b5302
Merge branch 'main' into truncate-no-such-dir 2022-01-29 09:58:17 +01:00
Sylvestre Ledru
cbc7da3d7d
Merge pull request #2936 from tertsdiepraam/clap-infer-long-args
all: enable infer long arguments in clap
2022-01-29 09:57:15 +01:00
Sylvestre Ledru
bd44c59043
Merge pull request #2945 from jfinkels/truncate-reduce-underflow
truncate: prevent underflow when reducing size
2022-01-29 09:55:29 +01:00
Sylvestre Ledru
52b7a725ed
Merge pull request #2938 from sylvestre/selinux-dep
selinux: add consistency in the dep declaration
2022-01-29 09:46:16 +01:00
Jeffrey Finkelstein
0454d3b243 truncate: prevent underflow when reducing size
Prevent usize underflow when reducing the size of a file by more than
its current size. For example, if `f` is a file with 3 bytes, then

    truncate -s-5 f

will now set the size of the file to 0 instead of causing a panic.
2022-01-28 22:44:07 -05:00
Jeffrey Finkelstein
c780c96e17 truncate: better error msg when dir does not exist
Improve the error message that gets printed when a directory does not
exist. After this commit, the error message is

    truncate: cannot open '{file}' for writing: No such file or directory

where `{file}` is the name of a file in a directory that does not
exist.
2022-01-28 21:21:37 -05:00
Terts Diepraam
5f1933a89f df: no longer override help 2022-01-29 02:06:32 +01:00
Terts Diepraam
9c8e865b55 all: enable infer long arguments in clap 2022-01-29 02:06:29 +01:00
Sylvestre Ledru
96584027e5 selinux: add consistency in the dep declaration 2022-01-29 01:31:17 +01:00
Sylvestre Ledru
f1d72018d7
Merge pull request #2923 from jfinkels/seq-error-zero-increment-value
seq: correct error message for zero increment
2022-01-29 01:25:57 +01:00
Sylvestre Ledru
c702154a84
Merge pull request #2934 from jfinkels/truncate-division-by-zero
truncate: add a division by zero error
2022-01-29 01:25:10 +01:00
Sylvestre Ledru
fed5ca4ba9
Merge pull request #2935 from tertsdiepraam/wc-unusual-files
wc: fix counting files from pseudo-filesystem
2022-01-29 01:09:02 +01:00
Sylvestre Ledru
b94bd96bc6 ignore spelling issue 2022-01-29 00:35:16 +01:00
Sylvestre Ledru
7f79fef2cd fix various doc warnings 2022-01-29 00:09:09 +01:00
Terts Diepraam
dd311b294b wc: fix counting files from pseudo-filesystem 2022-01-28 19:08:44 +01:00
electricboogie
72c53219e3 Prevent potential unwrap on a None value 2022-01-27 22:07:07 -06:00
Jeffrey Finkelstein
9dda23d8c6 seq: correct error message for zero increment
Change a word in the error message displayed when an increment value
of 0 is provided to `seq`. This commit changes the message from "Zero
increment argument" to "Zero increment value" to match the GNU `seq`
error message.
2022-01-27 21:17:27 -05:00
Jeffrey Finkelstein
b636ff04a0 split: implement -n option
Implement the `-n` command-line option to `split`, which splits a file
into a specified number of chunks by byte.
2022-01-27 21:16:27 -05:00
Jeffrey Finkelstein
1e5e637990 truncate: add a division by zero error
Add an error for division by zero. Previously, running `truncate -s /0
file` or `-s %0` would panic due to division by zero. After this
change, it writes an error message "division by zero" to stderr and
terminates with an error code.
2022-01-27 21:12:59 -05:00
Jeffrey Finkelstein
1074deeb03 truncate: make better use of UResult
Replace some uses of `crash!()` and move `UError` handling down into
the `truncate()` function. This does not change the behavior of the
program, just organizes the code to facilitate introducing code to
handle other types of errors in the future.
2022-01-27 21:05:34 -05:00
electricboogie
5e82d6069f Fix comments 2022-01-27 16:12:34 -06:00
Sylvestre Ledru
b816e80e2f
Merge pull request #2912 from jfinkels/truncate-create-non-existent-file
truncate: create non-existent file by default
2022-01-27 23:03:55 +01:00
electricboogie
463c1ac2ff Make suggested changes: Move logic into PathData struct, etc. 2022-01-27 11:57:19 -06:00
electricboogie
7512200ba2 Cleanup comments 2022-01-26 16:52:05 -06:00
electricboogie
1d629d8d66 Move more logic into md function, make enter_directory function clearer 2022-01-26 16:41:52 -06:00
Jeffrey Finkelstein
4fbe2b2b5e seq: implement -f FORMAT option
Add support for the `-f FORMAT` option to `seq`. This option instructs
the program to render each value in the generated sequence using a
given `printf`-style floating point format. For example,

    $ seq -f %.2f 0.0 0.1 0.5
    0.00
    0.10
    0.20
    0.30
    0.40
    0.50

Fixes issue #2616.
2022-01-25 20:48:26 -05:00
Sylvestre Ledru
c7fc0a703b
Merge pull request #2893 from g-k/2888-rand-0.8
update rand crate to 0.8
2022-01-25 23:23:43 +01:00
Sylvestre Ledru
5932937952
Merge pull request #2777 from jfinkels/uucore-printf
uucore: move printf::memo module to uucore
2022-01-25 23:22:27 +01:00
Sylvestre Ledru
5c45911c13
Merge pull request #2915 from jfinkels/dd-status-noxfer
dd: correct behavior when status=noxfer
2022-01-25 23:19:53 +01:00
Jeffrey Finkelstein
e8df666c2e dd: support seek=N when destination is stdout
Add support for the `seek=N` argument when the destination is stdout
and not a file. Previously, the argument was ignored when writing to
stdout.
2022-01-25 12:34:13 -05:00
Sylvestre Ledru
630b5d8577
Merge pull request #2909 from jfinkels/dd-conv-ascii-unblock
dd: block/unblock on ebcdic/ascii conversions
2022-01-25 14:37:20 +01:00
Sylvestre Ledru
b5df3723df
Merge pull request #2897 from tertsdiepraam/mdbook
Automatic mdBook Documentation
2022-01-25 14:33:41 +01:00
Sylvestre Ledru
1415ebc263
Merge pull request #2908 from cohosh/join_chkodr_default
join: fix default check order behaviour
2022-01-25 13:47:34 +01:00
Sylvestre Ledru
c74cfdc33e
Merge pull request #2916 from jfinkels/tail-follow-non-utf8-bytes
tail: don't error when following non-UTF-8 data
2022-01-25 13:47:16 +01:00
Sylvestre Ledru
e6733881d6
Merge pull request #2850 from sbentmar/numfmt-error-handling
numfmt: use UResult in more functions
2022-01-25 13:46:46 +01:00
Jeffrey Finkelstein
83f96ec29d tail: don't error when following non-UTF-8 data
Fix a bug where `tail -f` would terminate with an error due to failing
to parse a UTF-8 string from a sequence of bytes read from the
followed file. This commit replaces the call to `BufRead::read_line()`
with a call to `BufRead::read_until()` so that any sequence of bytes
regardless of encoding can be read.

Fixes #1050.
2022-01-24 21:32:52 -05:00
Greg Guthe
e6fdf0761f factor: ignore quickcheck tests using unhandled large vals
refs: #1559
2022-01-24 20:51:10 -05:00
Greg Guthe
e24ecea1da factor: tests: update Arbitrary impl for Factors
Upstream removed the Gen trait and made the gen method private in
d286e4db20
2022-01-24 20:41:22 -05:00
Greg Guthe
c037382df7 factor: update quickcheck dev dep to 1.0.3
quickcheck <1 uses rand 0.6.x which results in E0599 errors.  Upgrading resolves that error and lets
us remove the older rand version from our deps.

refs: https://stackoverflow.com/questions/56901973/errore0599-no-method-named-gen-found-for-type-mut-g-in-the-current-scope/56902740#56902740
2022-01-24 20:41:20 -05:00
Greg Guthe
a6f8d1d9fd shuf: fix crate relative import for vendored rand read adapter 2022-01-24 20:40:57 -05:00
Greg Guthe
2630894658 shuf: remove ReadRng deprecation notices 2022-01-24 20:40:57 -05:00
Greg Guthe
6bcca01e83 shuf: add deprecated rand crate ReadRng adapter
It is deprecated pending future removal. This version copied from:
https://github.com/rust-random/rand/blob/0.8.4/src/rngs/adapter/read.rs
2022-01-24 20:40:55 -05:00
Greg Guthe
a342df03f0 tests: update factor Distribution<Factors> sample to take range 2022-01-24 20:40:31 -05:00
Greg Guthe
cae6bc5e82 deps: update rand to 0.8
fix: #2888
2022-01-24 20:40:29 -05:00
Jeffrey Finkelstein
80ac2619e4 dd: correct behavior when status=noxfer
Correct the behavior of `dd` with the `status=noxfer` option. Before
this commit, the status output was entirely suppressed (as happens
with `status=none`). This was incorrect behavior. After this commit,
the input/output counts are printed to stderr as expected.

For example,

    $ printf "" | dd status=noxfer
    0+0 records in
    0+0 records out

This commit also updates a unit test that was enforcing the wrong
behavior.
2022-01-23 17:36:14 -05:00
Terts Diepraam
d2fe245192
Merge pull request #2502 from hbina/hbina-tr-reimplement-expansion
`tr`: Expanding expansion module
2022-01-23 19:08:00 +01:00
Jeffrey Finkelstein
129cfe12b8 truncate: create non-existent file by default
Fix the behavior of truncate when given a non-existent file so that it
correctly creates the file before truncating it (unless the
`--no-create` option is also given).
2022-01-23 11:24:53 -05:00
Jeffrey Finkelstein
1c8df122d7 dd: block/unblock on ebcdic/ascii conversions
Update `dd` so that the conversion `conv=ascii` implies `conv=unblock`
and, symmetrically, the conversion `conv=ebcdic` implies `conv=block`.
2022-01-23 09:57:37 -05:00
Cecylia Bocovich
594157d1e0
join: fix default check order behaviour
If neither --nocheck-order or --check-order are specified, only fail on
unsorted inputs if either file contains unpaired lines.
2022-01-22 17:51:29 -05:00
Terts Diepraam
7014607f0a Merge branch 'main' into mdbook 2022-01-22 12:42:19 +01:00
Jeffrey Finkelstein
f595edaded tail: fix a bug in tail [ -n | -c ] +NUM <file>
Fix a bug when getting all but the first NUM lines or bytes of a file
via `tail -n +NUM <file>` or `tail -c +NUM <file>`. The bug only
existed when a file is given as an argument; it did not exist when the
input data came from stdin.
2022-01-21 19:05:53 -05:00
Jeffrey Finkelstein
d27d6bc32c split: add forwards_thru_file() helper function
Add helper function `forwards_thru_file()` that finds the index in a
reader of the byte immediately following the `n`th instance of a given
byte.
2022-01-21 18:33:15 -05:00
Jeffrey Finkelstein
58d84d5107 tail: support zero-terminated lines in streams
Support `-z` option when the input is not a seekable file. Previously,
the option was accepted by the argument parser, but it was being
ignored by the application logic.
2022-01-21 18:31:15 -05:00
Sylvestre Ledru
8c298e97a5
expr: Fix a warning in the doc generation (#2900)
```
warning: this URL is not a hyperlink
```
2022-01-21 23:14:05 +01:00
Terts Diepraam
ab3623f65a docs: usage and values for options 2022-01-21 19:20:55 +01:00
Cecylia Bocovich
67878de379
join: print unsorted line in error message
This expands the error message that is printed if either input file has
an unsorted line. Both the program name (join) and the offending line
are printed out with the message to match the behaviour of the GNU
utility.
2022-01-21 11:47:37 -05:00
Terts Diepraam
9ddd61ab6b Merge branch 'main' into hbina-tr-reimplement-expansion 2022-01-21 14:42:30 +01:00
Terts Diepraam
55a47f6fc0
Merge pull request #2863 from tertsdiepraam/clap-3
Clap 3
2022-01-20 23:14:52 +01:00
Sylvestre Ledru
d64b32d121
Merge pull request #2885 from jfinkels/head-find-nth-line-from-end
head: refactor helper function find_nth_line_from_end()
2022-01-20 21:53:47 +01:00
electricboogie
0b53cd8c4a Make suggested changes 2022-01-20 14:52:45 -06:00
Terts Diepraam
b51a6e8fe3 tr: make parsing of sets more terse 2022-01-19 21:03:57 +01:00
Terts Diepraam
da728dd2b6 Merge branch 'main' into hbina-tr-reimplement-expansion 2022-01-19 19:34:13 +01:00
Terts Diepraam
6aa433c70a tr: adapt copyright to new guidelines 2022-01-19 19:07:17 +01:00
Roy Ivy III
2e251f91f1 0.0.12 2022-01-19 05:35:00 -06:00
Jeffrey Finkelstein
ca812a7558 tail: rm trailing \n if input doesn't end with one
Fix a bug where `tail` would inappropriately add a newline to the last
line of output even though the input did not end with one.
2022-01-18 17:34:41 -05:00
Terts Diepraam
4b79419514 runcon/hashsum: remove references to get_matches_from_safe 2022-01-18 16:34:06 +01:00
Terts Diepraam
0a30c43bb6 chcon: use try_get_matches_from 2022-01-18 13:06:02 +01:00
Terts Diepraam
e345768484 base64: remove clap dependency again 2022-01-18 12:56:58 +01:00
Terts Diepraam
270a6ee83e rm: fix 3 leading hyphens for ---presume-input-tty 2022-01-18 12:54:50 +01:00
Justin Tracey
ce3df12eaa join: "support" field numbers larger than usize::MAX
They silently get folded to usize::MAX, which is the official GNU behavior.
2022-01-17 17:49:41 -05:00
Jeffrey Finkelstein
e575007629 tail: improve error handling when file not found 2022-01-17 10:57:24 -05:00
Jeffrey Finkelstein
0f1053ce68 head: refactor helper func find_nth_line_from_end
Factor out a loop for finding the index of the byte immediately
following the `n`th line from the end of a file. This does not change
the behavior of the code, just its organization.
2022-01-17 10:55:40 -05:00
Terts Diepraam
951f3bb689 fix up runcon and chcon for clap 3 2022-01-17 16:52:17 +01:00
Terts Diepraam
55893f0e3d od: use clap options instead of custom mock options for unit tests 2022-01-17 16:25:49 +01:00
sbentmar
b0cf6f9b34 numfmt: minor adjustments to test cases 2022-01-17 16:24:40 +01:00
sbentmar
635c2d0c31 numfmt: remove unused function 2022-01-17 16:24:40 +01:00
sbentmar
1287ce3780 numfmt: add tests for handle_buffer 2022-01-17 16:24:40 +01:00
sbentmar
4a7d313712 numfmt: add unit test for io error 2022-01-17 16:24:40 +01:00
sbentmar
5cab4e41b3 numfmt: add copyright notice 2022-01-17 16:24:40 +01:00
Sebastian Holgersson
9b04c98ddb numfmt: use UResult in more functions
This commit replaces generic Results with UResults in some key
functions in numfmt. As a result of this, we can provide different
exit codes for different errors, which resolves ~70 failing test
cases in the GNU numfmt.pl test suite.
2022-01-17 16:24:40 +01:00
Jeffrey Finkelstein
ab4036297b head: use uucore error handling instead of custom
Use `show!()` and `USimpleError` to handle I/O errors instead of using
custom code.
2022-01-17 08:58:44 -05:00
Jeffrey Finkelstein
58f2000406 split: method to convert ArgMatches to Settings
Create a `Settings::from` method that converts a `clap::ArgMatches`
instance into a `Settings` instance. This eliminates the unnecessary
use of a mutable variable when initializing the settings.
2022-01-17 08:58:10 -05:00
Jeffrey Finkelstein
d9afdf0527 uucore: move printf::memo module to uucore
Move the `printf::memo` module to `uucore` so that it can be used by
other programs, not just `printf`. For example, the `-f` option to `seq`
requires parsing and formatting numbers according to the same logic as
`printf`.
2022-01-17 08:46:45 -05:00
Jeffrey Finkelstein
2d66c84413 printf: remove cli module
Remove the cli module from the printf crate and move its functions into
the module tokenize::unescaped_text module, the only place they are
used.
2022-01-17 08:43:36 -05:00
Terts Diepraam
8872485922 Merge branch 'main' into clap-3 2022-01-17 13:25:51 +01:00
Terts Diepraam
08efa1fe5a
Merge branch 'main' into join-null-field-sep 2022-01-17 12:59:52 +01:00
Sylvestre Ledru
a87a71893f
Merge pull request #2879 from sylvestre/chrono-issue
Force minimal version of chrono to avoid a security issue
2022-01-17 12:53:31 +01:00
Justin Tracey
109277d405 join: add support for -t '\0' 2022-01-16 18:05:58 -05:00
Justin Tracey
346415e1d2 join: add support for -z option 2022-01-16 17:56:07 -05:00
Sylvestre Ledru
fcff6fec6d Force minimal version of chrono to avoid a security issue
See: https://rustsec.org/advisories/RUSTSEC-2020-0071.html
2022-01-16 23:33:12 +01:00
Sylvestre Ledru
4fc47aba61
Merge pull request #2878 from tertsdiepraam/stdbuf-trouble
`stdbuf`: fix `cargo publish` problem
2022-01-16 23:23:35 +01:00
Sylvestre Ledru
516bdfcfd5
Merge pull request #2872 from jfinkels/split-verbose
split: add --verbose option
2022-01-16 23:19:30 +01:00
Terts Diepraam
c5e2515833 fix stdbuf problem 2022-01-16 22:50:34 +01:00
electricboogie
16b7b38b92 Run cargo fmt 2022-01-16 11:17:43 -06:00
electricboogie
e6ce049d2c Fix Windows lints/build errors 2022-01-16 11:07:22 -06:00
electricboogie
e1bffea595 Merge branch 'master' into ls_bad_fd_2 2022-01-16 10:26:44 -06:00
electricboogie
15efba54c5 Use dir_entry metadata for dereferenced bad fds to match GNU, add comments, clippy lints 2022-01-16 10:20:50 -06:00
Sylvestre Ledru
1fbda8003c coreutils 0.0.8 => 0.0.9, uucore_procs 0.0.7 => 0.0.8, uucore 0.0.10 => 0.0.11 2022-01-16 17:05:48 +01:00
Sylvestre Ledru
00c11b184f
Merge pull request #2851 from jtracey/join-strless
join: operate on bytes instead of Strings
2022-01-16 16:24:38 +01:00
Terts Diepraam
448b84806f
fix Rust 1.58 clippy lints (#2874) 2022-01-16 15:57:33 +01:00
Jeffrey Finkelstein
7af3007204 split: add --verbose option 2022-01-16 09:34:28 -05:00
electricboogie
37ca6edfdc Fix display of bad fd errors 2022-01-15 22:39:07 -06:00
kimono-koans
fd5310411e
ls: Fix device display (#2855) 2022-01-15 00:39:56 +01:00
Sylvestre Ledru
3cc1fb593a
Merge pull request #2859 from jfinkels/split-dynamic-suffix-length
split: correct filename creation algorithm
2022-01-14 18:06:57 +01:00
Terts Diepraam
49e5412580 tsort: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
e62fdb9307 yes: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
fe69ad25f8 whoami: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
e3b8e6c993 who: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
e9e5768591 wc: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
e5a775be46 users: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
ac76eefb99 uptime: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
2cd32beb70 unlink 2022-01-11 19:16:48 +01:00
Terts Diepraam
5105a59fda uniq: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
dafa0737c8 unexpand: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
7de993fa4f uname: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
48c65934c7 tty: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
263357666f truncate: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
6c37cdebce true: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
fd777866a3 tr: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
9f58715d65 touch: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
7318d1d24b timeout: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
0ff1984471 test: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
3cac8a631f tee: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
9c9643807a tail: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
219498c2e8 tac: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
57361292aa sync: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
bad790840a sum: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
0fca4460de stdbuf: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
eaaa16291e stat: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
ecf6f18ab3 split: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
b43839a8a8 sort: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
d0a52c95e6 sleep: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
793e540323 shuf: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
92e94de2d7 shred: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
41513a8ba6 seq: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
ec42e824f0 runcon: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
4edab26dcc pr: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
f260f60093 rmdir: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
283973c5bf rm: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
a02e40fcad relpath: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
d52887e6c0 pwd: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
edafc468ed realpath: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
d8f2be2f3b readlink: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
24dc4d9037 ptx: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
b94809197f printf: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
8ba10936b0 printenv: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
c39a9b49d4 pinky: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
49b19972cc pathchk: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
8f7f3d18ee paste: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
9efd6654f8 od: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
7cebb2563b numfmt: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
5702313e9c nproc: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
5e9443567d nohup: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
5b13ec9c66 nl: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
64f57a9200 nice: clap 3 2022-01-11 19:16:48 +01:00
Terts Diepraam
ba93684a7e mv: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
41d567f44b more: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
f902ec7d6e mktemp: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
6e39eddbc1 mknod: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
c8eddad610 mkfifo: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
0e021e956a mkdir: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
c8270b202e ls: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
ebaf5caae8 logname: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
9951958b93 ln: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
0531f13cfd link: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
83f39619d5 kill: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
b61494337e join: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
89112fb1c2 install: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
8c58f8e2b1 id: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
82aadbf38f hostname: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
6876521b08 hostid: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
9fc9fdb1f3 head: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
6e34d8a53c hashsum: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
742fe8500c groups: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
ebe96f1454 fold: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
e3e35cb1a9 fmt: clap 3 2022-01-11 19:16:47 +01:00