Commit graph

5973 commits

Author SHA1 Message Date
Sylvestre Ledru
b0becf0054
Merge pull request #2410 from hbina/hbina-touch-add-as-common-build
Add touch as a common core utility
2021-08-28 12:39:20 +02:00
Sylvestre Ledru
2b9196d6fa
Merge pull request #2600 from 353fc443/env-uresult
env: added UResult
2021-08-28 12:38:32 +02:00
Sylvestre Ledru
85c7178b10
Merge pull request #2609 from jfinkels/seq-negative-zero-start
seq: print negative zero at start of integer sequence
2021-08-28 12:32:50 +02:00
Sylvestre Ledru
064454bcce
Merge pull request #2571 from miDeb/chmod/compat
chmod: improve compatibility
2021-08-28 12:31:48 +02:00
Sylvestre Ledru
0525d9bf6a
Remove useless import of USimpleError 2021-08-28 11:44:34 +02:00
Sylvestre Ledru
0e49913b84
Merge branch 'master' into chmod/compat 2021-08-28 11:21:26 +02:00
Sylvestre Ledru
33055f7152
Merge pull request #2597 from miDeb/resolve-dangling
uucore/fs: use the latest resolution that did not fail
2021-08-28 09:55:44 +02:00
Sylvestre Ledru
1493027f27
remove the env: 2021-08-28 09:55:15 +02:00
Sylvestre Ledru
aa07f4f3d6
Merge pull request #2608 from tertsdiepraam/ls/fix-tilde-hash-quote
ls: only quote ~ and # when they appear at the start of the name
2021-08-28 09:54:23 +02:00
Jeffrey Finkelstein
2c66d9e0a7 seq: print negative zero at start of integer seq. 2021-08-27 21:44:09 -04:00
Jeffrey Finkelstein
1df9a1691c seq: combine first, inc, last parameters into type
Combine the `first`, `increment`, and `last` parameters of the
`print_seq()` and `print_seq_integers()` functions into a `RangeF64` or
`RangeInt` type, respectively.
2021-08-27 21:30:33 -04:00
Jan Verbeek
afb460f4ca rmdir: match GNU
- Implement all of GNU's fiddly little details
- Don't assume Linux for error codes
- Accept badly-encoded filenames
- Report errors after the fact instead of checking ahead of time
- General cleanup

rmdir now passes GNU's tests.
2021-08-28 02:26:01 +02:00
Jan Verbeek
1c05183083 Move strip_errno to libcore 2021-08-28 02:26:01 +02:00
Jan Verbeek
d285472210 GNU tests: make script runnable from any directory 2021-08-28 02:26:01 +02:00
Jan Verbeek
58ce3d1e82 Make scripts executable 2021-08-28 02:26:01 +02:00
Terts Diepraam
d5dd4f6cff ls: only quote ~ and # when they appear at the start of the name
For example, we quote '~a' and '~' but not a~
2021-08-27 15:39:04 +02:00
Sylvestre Ledru
406e60eef2 make build-gnu.sh executable 2021-08-27 09:28:43 +02:00
Sylvestre Ledru
26dcd01713
Merge pull request #2603 from uutils/miDeb-patch-1
doc: Add instructions to run GNU tests
2021-08-26 12:39:14 +02:00
Michael Debertol
1ab128fb8d
add spell checker exception 2021-08-26 12:00:27 +02:00
Michael Debertol
d7ff2ce5ad
doc: Add instructions to run GNU tests 2021-08-26 11:49:45 +02:00
Jan Verbeek
94e33c97f3 wc: Add benchmarking documentation 2021-08-26 01:38:16 +02:00
Jan Verbeek
1358aeecdd wc: Avoid unnecessary work in general loop
This gives a big speedup if e.g. only characters are being counted.
2021-08-26 01:38:16 +02:00
Jan Verbeek
f50b004860 wc: Adjust expected report for directories for Windows 2021-08-26 01:38:16 +02:00
Jan Verbeek
4943517327 wc: Adjust expected error messages for Windows 2021-08-26 01:38:16 +02:00
Jan Verbeek
0f1e79fe29 wc: Fix linters 2021-08-26 01:38:16 +02:00
Jan Verbeek
9972cd1327 wc: Report counts and failures correctly
If reading fails midway through then a count should be reported for
what could be read.

If opening a file fails then no count should be reported.

The exit code shouldn't report the number of failures, that's fragile
in case of many failures.
2021-08-26 01:38:16 +02:00
Jan Verbeek
c16e492cd0 wc: Make output width more consistent with GNU 2021-08-26 01:38:16 +02:00
Jan Verbeek
d0c0564947 wc: Swap order of characters and bytes in output
This way it matches GNU and busybox.
2021-08-26 01:38:16 +02:00
Jan Verbeek
657a04f706 wc: Stricter simpler error handling
Errors are now always shown with the corresponding filename.

Errors are no longer converted into warnings. Previously `wc < .`
would cause a loop.

Checking whether something is a directory is no longer done in
advance. This removes race conditions and the edge case where stdin is
a directory.

The custom error type is removed because io::Error is now enough.
2021-08-26 01:38:16 +02:00
Jan Verbeek
35793fc260 wc: Accept badly-encoded filenames 2021-08-26 01:38:16 +02:00
Jan Verbeek
6f7d740592 wc: Do a chunked read with proper UTF-8 handling
This brings the results mostly in line with GNU wc and solves nasty
behavior with long lines.
2021-08-26 01:38:16 +02:00
Jan Verbeek
48437fc49d wc: Optimize, improve correctness
- Reuse allocations for read lines
- Increase splice size
- Check if /dev/null was opened correctly
- Do not discard read bytes after I/O error
- Add fast line counting with bytecount
2021-08-26 01:38:16 +02:00
353fc443
d4697d9883
env: added UResult 2021-08-25 22:02:35 +05:30
Andreas Hartmann
c756878b20 backup_control: Use C-locale quotes in outputs 2021-08-25 16:33:50 +02:00
Andreas Hartmann
8ecef029f6 mv: Adapt to modified backup_control interface 2021-08-25 16:33:50 +02:00
Andreas Hartmann
2a1a923acc ln: Adapt to modified backup_control interface 2021-08-25 16:33:50 +02:00
Andreas Hartmann
ce0d9bce28 install: Adapt to modified backup_control interface 2021-08-25 16:33:50 +02:00
Andreas Hartmann
f2311f87f4 cp: Adapt to modified backup_control interface 2021-08-25 16:33:50 +02:00
Andreas Hartmann
6c86957a24 backup_control: Fix internal tests
Adapt the tests to work with the changed function interfaces. Added a
convenience function to construct a `clap` application that's used to test the
functions from a "user"-perspective.
2021-08-25 16:33:50 +02:00
Andreas Hartmann
6f4e43e7c6 backup_control: Update docs
Add documentation to the module itself and update existing documentations for
functions whose interfaces changed. Add more doctests.
2021-08-25 16:33:50 +02:00
Andreas Hartmann
e132fd49d9 backup_control: Rework function interfaces
Change all relevant functions to return `UResult`s from `BackupError` instead
of error strings. Make `determine_backup_mode/suffix` accept `clap::ArgMatches`
as input argument to parse for the arguments themselves, using the arguments
with are defined in the `arguments` submodule.

This way the user only needs to include the pre-defined arguments from the
`arguments` module and passes a reference to the applications `ArgMatches` into
the respective functions here. The functions then take care of handling the
arguments. It is recommended to use the arguments provided in the `arguments`
module over custom-defined ones.
2021-08-25 16:33:50 +02:00
Andreas Hartmann
54086ef4c5 backup_control: Implement custom error type
Implements an error type based on `UError` that replaces the previously used
error strings. The errors are currently returned when determining the backup
mode, but extensions for future uses are already in place as comments.
2021-08-25 16:33:50 +02:00
Andreas Hartmann
2c6410f4d8 backup_control: Add arguments module
Contains functions that create the CLI arguments associated with the backup
functionality.
2021-08-25 16:33:50 +02:00
Sylvestre Ledru
baebefcb6a
Merge pull request #2442 from sylvestre/doc
Document the source documentation + document some modules
2021-08-25 14:09:01 +02:00
Andreas Hartmann
4fbb741314 macros: Remove obsolete macros
Removes the `return_if_err!` and `safe_unwrap!` macros, which have now
been replaces by `crash_if_err!` throughout the whole code and thus
aren't used any longer.
2021-08-25 13:59:39 +02:00
Andreas Hartmann
1755195251 uu: Replace return_if_err with crash_if_err
Unify the usage of macros `return_if_err` and `crash_if_err`. As
`return_if_err` is used only in `uumain` routines of utilities, it
achieves the same thing as `crash_if_err`, which calls the `crash!`
macro to terminate function execution immediately.
2021-08-25 13:59:39 +02:00
Andreas Hartmann
229948ae45 uu: Replace safe_unwrap with crash_if_err
Unify the usage of macros `safe_unwrap` and `crash_if_err` that are
identical to each other except for the assumption of a default error
code. Use the more generic `crash_if_err` so that `safe_unwrap` is now
obsolete and can be removed.
2021-08-25 13:59:39 +02:00
Michael Debertol
5ab05a9219 chmod: remove redundant cfg
redox is unix.
2021-08-25 13:52:09 +02:00
Michael Debertol
5121e2eec1 chmod: add check for quiet 2021-08-25 13:52:09 +02:00
Michael Debertol
38afdd6ab4 uucore/mode: add cast for some platforms 2021-08-25 13:52:09 +02:00