Sylvestre Ledru
522d4d39e3
Merge pull request #2680 from blyxxyz/utmpx-safety
...
uucore::utmpx: Make thread-safe
2021-09-18 16:15:52 +02:00
Jeffrey Finkelstein
f95ab2f43c
uucore(panic): guard against "Broken pipe" panics
...
Add "Broken pipe" to the set of panic messages used to determine whether
a panic is caused by a broken pipe error.
2021-09-14 21:26:50 -04:00
Jan Verbeek
519c0d16b3
uucore::utmpx: Make thread-safe
2021-09-14 21:17:50 +02:00
Michael Debertol
5c97c1ccc4
Merge pull request #2678 from blyxxyz/io-error-detect-os
...
Do not discard non-OS error messages
2021-09-14 20:21:48 +02:00
Jan Verbeek
601ea3ef19
uucore::process: Add a few notes
2021-09-14 19:55:00 +02:00
Jan Verbeek
cc652c7fe9
uucore::mode: Add notes about umask and platform support
2021-09-14 19:54:40 +02:00
Jan Verbeek
8cfe0290cd
uucore::fsext: Avoid unnecessary allocations
2021-09-14 18:28:09 +02:00
Jan Verbeek
9d5133157a
uucore::fsext: Replace some unsafe calls
...
GetLastError() and libc::stat() were unnecessary as libstd offered
equivalents.
LPWSTR2String() was technically unsafe if passed a slice without
zeroes, but it's a private function and was probably always called
correctly in practice.
2021-09-14 18:28:09 +02:00
Jan Verbeek
1edd2bf3a8
Do not discard non-OS error messages
2021-09-14 15:11:54 +02:00
Sylvestre Ledru
2a4422997d
Restrict some crates to specific OS
2021-09-13 22:45:55 +02:00
Jan Verbeek
d6a8485115
uucore::pipes: Expand documentation
2021-09-10 22:03:51 +02:00
Jan Verbeek
c1079e0b1c
Move common pipe and splice functions into uucore
...
This cuts down on repetitive unsafe code and repetitive code in
general.
2021-09-10 21:24:34 +02:00
Andreas Hartmann
6fec0bfe24
macros: Add documentation with examples to macros
2021-09-10 08:39:49 +02:00
Jan Verbeek
259f18fcab
Update message quoting and filename printing
2021-09-07 19:49:01 +02:00
Jan Verbeek
60df3c6b7c
uucore: Cache args_os(), util_name(), execution_phrase()
...
And remove args() because there's no valid use for it, invalid unicode
handling is specified in a different way.
2021-09-07 18:51:25 +02:00
Jan Verbeek
7791207870
Preserve error message for "other" I/O errors
...
These errors still have a unique message even if the ErrorKind enum
doesn't classify them.
2021-09-06 23:24:31 +02:00
David Carlier
5587face61
fsext build fix for OpenBSD.
...
prioritising statfs over statvfs for this platform.
2021-09-05 13:06:25 +01:00
Sylvestre Ledru
6226a03214
Merge pull request #2624 from miDeb/cp/acl
...
cp: correctly copy mode, ownership, acl and context
2021-09-03 20:18:13 +02:00
Michael Debertol
d1c3a8f69a
uucore/perms: remove erroneous comment
2021-09-03 14:37:47 +02:00
Michael Debertol
435b7a22fb
uucore/perms: add more information to an error message
...
This reverts part of https://github.com/uutils/coreutils/pull/2628 ,
because (even though it got the test passing) it was the wrong bug fix.
2021-09-03 00:50:04 +02:00
Michael Debertol
a7f6b4420a
uucore/perms: take traverse_symlinks into account
2021-09-03 00:50:04 +02:00
Michael Debertol
a4fca2d4fc
uucore/perms: remove flags in favor of enums
...
Part of the code was transliterated from GNU's implementation in C,
and used flags to store settings. Instead, we can use enums to avoid
magic values or binary operations to extract flags.
2021-09-03 00:50:04 +02:00
Michael Debertol
195f827cd4
chown/chgrp: share more code
...
Also share argument parsing code between `chgrp` and `chown`
2021-09-03 00:50:04 +02:00
Michael Debertol
18fc4076cf
uucore/perms: correct some error messages
...
- prevent duplicate errors from both us and `walkdir` by instructing `walkdir'
to skip directories we failed to read metadata for.
- don't directly display `walkdir`'s errors, but format them ourselves to
match gnu's format
2021-09-01 18:40:06 +02:00
Jan Verbeek
7bf85751b0
uucore::display: Fix tests
2021-09-01 00:37:21 +02:00
Michael Debertol
8b74562820
cp: correctly copy mode, ownership, acl and context
...
Fix a mix-up between ownership and mode. The latter (mode / file permissions)
can also be set on windows (which however only affects the read-only flag),
while there doesn't seem to be a straight-forward way to change file ownership
on windows.
Copy the acl as well when copying the mode. This is a non-default feature and can be
enabled with --features feat_acl, because it doesn't seem to work on CI.
It is only available for unix so far.
Copy the SELinux context if possible.
2021-09-01 00:16:22 +02:00
Jan Verbeek
3dd6f79880
uucore::display: Remove escape_control, tweak special characters
2021-08-31 22:07:24 +02:00
Jan Verbeek
f0f13fe1f0
uucore::display: Simplify
...
The different quoting implementations are similar enough to merge
parts of them.
2021-08-31 22:07:24 +02:00
Jan Verbeek
a93959aa44
uucore::display: impl Quotable for Cow<str>, add escape_control
2021-08-31 22:07:24 +02:00
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
Terts Diepraam
ea3c15f0dd
uucore: use default UError impl for UIoError
2021-08-10 17:55:37 +02:00
Terts Diepraam
d12d4f760c
uucore: {USimpleError, UUsageError}::new take Into<String> instead of String
2021-08-10 17:55:37 +02:00
Terts Diepraam
1649217116
uucore: remove distinction between common and custom errors
...
As custom errors are prefered over wrapping around common errors, the
distinction between UCommonError and UCustomError is removed. This
reduces the number of types and makes the error handling easier to
understand.
2021-08-10 17:55:28 +02:00
Sylvestre Ledru
ca0bae0dfd
Merge pull request #2500 from Funky185540/feature/install-use-uresult
...
install: Use UResult
2021-08-10 13:32:00 +02:00
Jeremy Soller
cc0e1e3458
core/entries: disable missing group functions on redox
2021-08-06 13:56:20 -06:00
Jeremy Soller
3601eaf176
core: only require dns-lookup when utmpx feature is required
2021-08-06 13:56:20 -06:00
Jeremy Soller
318366c900
core/fsext: provide stub for read_fs_list on redox
2021-08-06 13:56:20 -06:00
Jeremy Soller
cbac771340
core/fs: remove unused import on redox
2021-08-06 13:56:20 -06:00
Jeremy Soller
d672fe098e
core/fsext: use statvfs on redox
2021-08-06 13:56:20 -06:00
Jeremy Soller
073d6b5908
core/mode: use libc::umask on redox
2021-08-06 13:56:20 -06:00
Jeremy Soller
1cf95c06ea
core: do not build utmpx feature on redox
2021-08-06 13:56:20 -06:00
Michael Debertol
b8c383e210
basenc: add utility
...
basenc is a brand-new gnu core utility (added less than 3 years ago!),
which enables some more encodings.
2021-08-06 00:07:19 +02:00
Michael Debertol
e8eb15f05e
core/error: require UCustomError to be Send
...
For multi-threaded programs like sort it is necessary to be able to send
errors between threads.
2021-08-01 21:27:59 +02:00
James Robson
0e04f959c2
Add Physical mode to realpath
...
This adds the 'Physical Mode' and 'Logical Mode' switches to realpath, which control when symlinks are resolved.
2021-08-01 17:06:09 +01:00
Andreas Hartmann
8066ea87cc
error: Implement uio_error
-macro
...
Adds a new macro `uio_error` that acts as a convenience wrapper for
constructing `UIoError` instances from `std::io::Error`s with a custom error
message prepended. It constructs a new `UIoError` instance for the user.
Usage examples are included in the docs.
2021-07-31 13:06:37 +02:00
sagu
9702aa6414
Revert "silent buggy clippy warning"
2021-07-25 18:06:41 +02:00
Terts Diepraam
eae8c72793
Merge pull request #2467 from Funky185540/backup_mode_determination
...
backup_control: Fix backup mode determination
2021-07-20 13:27:04 +02:00
Andreas Hartmann
250bcaf7c5
backup_control: Run tests in series
...
Make all tests lock a mutex to ensure that they're run in series rather than
parallel. We must take this precaution due to the fact that all tests are run
in parallel as threads of one parent process. As all threads in a process share
e.g. environment variables, we use the Mutex to ensure they're run one after
another.
This way we can guarantee that tests that rely on environment variables to have
specific values will see these variables, too.
An alternative implementation could have used the [rusty fork][1] crate to run
all tests that need env variables in separate processes rather than threads.
However, rusty fork likely wouldn't run on all platforms that the utilities are
supposed to run on.
2021-07-19 17:01:49 +02:00
Andreas Hartmann
3a5caec5c2
uucore: error: Add docs to the code
and usage
functions
...
Make it plain what each of the functions is meant to implement and how they are
supposed to work.
2021-07-19 08:53:35 +02:00
Sylvestre Ledru
f37446eb1f
update uucore to 0.0.9
2021-07-11 18:03:18 +02:00
Andreas Hartmann
a783d05101
backup_control: Add module tests
...
Adds a tests submodule that performs tests on the
`determine_backup_mode` function to ensure it handles backup options
like specified by [GNU][1].
[1]: https://www.gnu.org/software/coreutils/manual/html_node/Backup-options.html
2021-07-05 12:44:44 +02:00