Commit graph

305 commits

Author SHA1 Message Date
Jan Verbeek
13bb263a50 uucore::display: Support unquoted text 2021-08-31 22:07:24 +02:00
Jan Verbeek
0e1f8f7b34 Move verbatim path printing to uucore::Display 2021-08-31 22:07:24 +02:00
Jan Verbeek
4f891add5a uucore: Add a Quotable extension trait for displaying filenames 2021-08-31 22:07:24 +02:00
Michael Debertol
b82401e744 uucore: fall back to stripping the error message for unexpected io error kinds
Rust recently added new error kinds, which causes tests to fail on beta/nightly.
However, we can't match for these new error kinds because they are marked as unstable.
As a workaround we call `.to_string()` on the original error and strip
the ` (os error XX)` bit. The downside of this is that
the error messages are not capitalized.
2021-08-31 00:36:35 +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
Jan Verbeek
1c05183083 Move strip_errno to libcore 2021-08-28 02:26:01 +02:00
Andreas Hartmann
c756878b20 backup_control: Use C-locale quotes in outputs 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
Michael Debertol
38afdd6ab4 uucore/mode: add cast for some platforms 2021-08-25 13:52:09 +02:00
Michael Debertol
945e57ea22 chmod: show an error if a permission wasn't removed due to umask 2021-08-25 13:52:09 +02:00
Michael Debertol
15b40f6aa2 chmod: implement special handling of directory setuid/setgid 2021-08-25 13:52:09 +02:00
Michael Debertol
9697c89d17 uucore/mode: handle mode 0
Trimming all '0' characters results in an invalid string if the string
contained only '0's.
2021-08-25 13:52:09 +02:00
Jan Verbeek
e5d6c6970b yes: Cleanup
Report errors properly instead of panicking.

Replace zero_copy by a simpler specialized private module.

Do not assume splices move all data at once.

Use the modern uutils machinery.

Remove the "latency" feature. The time it takes to prepare the buffer
is drowned out by the startup time anyway.

yes: Add tests

yes: Fix long input test on Windows
2021-08-25 13:45:44 +02:00
Sylvestre Ledru
eb6ab9f883 Document some modules 2021-08-24 23:00:00 +02:00
Sylvestre Ledru
111d3e37bb
Merge pull request #2570 from miDeb/chgrp/no-duplication
chgrp/chown: move common code to `uucore`
2021-08-24 21:58:15 +02:00
Sylvestre Ledru
7c62337229
Merge pull request #2589 from devnexen/itmpx_netbsd
uucore netbsd update
2021-08-24 21:57:22 +02:00
Michael Debertol
ea41cc0ff6 uucore/fs: use the latest resolution that did not fail
When we ignore failures resolving symbolic links we should keep the
latest resolution that did not fail, not the original path.
2021-08-24 21:18:10 +02:00
Jan Verbeek
d06c074829 Run clippy on the full workspace
These lints were cluttering up the "problems" tab in my VS
Code. `--workspace` fixes the disparity.
2021-08-24 17:10:16 +02:00
Michael Debertol
4e251706be refactor: move shared chown logic to uucore 2021-08-24 15:22:05 +02:00
Michael Debertol
7153a595c6 chgrp: forward to chown
chgrp does mostly the same as chown.
By making chown a bit more configurable we can reuse its code for chgrp.
2021-08-24 15:22:05 +02:00
David Carlier
554d53c0ed uucore netbsd update
fsext build fix and utmpx implementation proposal.
2021-08-23 16:21:18 +01:00
Sylvestre Ledru
114c9a409c
Merge pull request #2471 from miDeb/real-exe-name
make executable!() return the real executable name
2021-08-22 16:55:06 +02:00
Sylvestre Ledru
8337aeb4d6 bump a few crates to simplify Debian packaging 2021-08-21 23:34:45 +02:00
Michael Debertol
5e07d58a4d
Merge pull request #2459 from jaggededgedjustice/realpath-add-physical-mode
Add Physical mode to realpath
2021-08-21 02:01:10 +02:00
Michael Debertol
252220e9eb refactor/uucore ~ make util_name and execution_phrase functions
Since util_name and execution_phrase no longer rely on features that are
only available to macros, they may as well be plain functions.
2021-08-14 17:55:18 +02:00
Michael Debertol
5f2335829a refactor ~ revert to single quotes for "Try '{0 --help'"
This is a test expectation for gnu.
2021-08-14 17:22:09 +02:00
Michael Debertol
3039083521 refactor/uucore ~ mark executable!() as deprecated
Make sure that utilities do not use it anymore.
It is only allowed as  an implementation detail of util_name!() and execution_phrase!()
2021-08-14 14:19:05 +02:00
Michael Debertol
44981cab01 refactor/uucore ~ correct implementation of executable!() for multicall
- Use an atomic bool to track whether the utility name is the second
or the first argument.
- Add tests
2021-08-14 14:01:34 +02:00
Roy Ivy III
c0854000d1 refactor ~ use execution_phrase!() for usage messaging 2021-08-14 14:01:33 +02:00
Roy Ivy III
318f366ace change/uucore ~ add execution_phrase!() macro for use with usage messages 2021-08-14 13:58:45 +02:00
Roy Ivy III
f56fc5bf44 refactor/uucore ~ use uucore args for executable macros 2021-08-14 13:58:45 +02:00
Roy Ivy III
69ce4dc8e5 refactor/uucore ~ align return values for executable/util macros 2021-08-14 13:58:45 +02:00
Roy Ivy III
eb13533e4e refactor/uucore ~ replace executable_name!() with util_name!() in standard messaging 2021-08-14 13:58:45 +02:00
Roy Ivy III
894d9a068c refactor ~ standardize on 'Try {} --help...' messaging (common markdown-type formatting) 2021-08-14 13:55:11 +02:00
Roy Ivy III
fa5dc90789 refactor/uucore ~ improve macro scope hygiene 2021-08-14 13:51:36 +02:00
Roy Ivy III
ed240a7e50 fix/uucore ~ revise and fix msg macros and sub-macros 2021-08-14 13:51:36 +02:00
Roy Ivy III
065330c4ca refactor/uucore ~ improve crash!() (DRY use of exit!()) 2021-08-14 13:51:36 +02:00
Roy Ivy III
27c4530f3c refactor/uucore ~ reorganize macros into sections by 'type' 2021-08-14 13:51:36 +02:00
Roy Ivy III
be8f073217 refactor/uucore ~ add OsString support for executable!() 2021-08-14 13:51:36 +02:00
Michael Debertol
6f58da00dd refactor/uucore ~ add util_name!(); correct implementation of executable!() 2021-08-14 13:51:36 +02:00
Sylvestre Ledru
ea5097e4a0
Merge pull request #2562 from tertsdiepraam/uucore/simpler-uerror
`uucore`: simpler `UResult` and `UError`
2021-08-13 01:33:23 +02:00
Michael Debertol
1c30fb42d2 chgrp: handle empty group 2021-08-11 19:03:41 +02:00
Terts Diepraam
14459cf611 rustfmt 2021-08-10 19:18:09 +02:00