Commit graph

511 commits

Author SHA1 Message Date
Terts Diepraam
37ab05bd7a cp: clap 3 2022-01-11 19:16:47 +01:00
Terts Diepraam
c76a06e6ea uucore: clap 3 2022-01-11 19:16:47 +01:00
Sylvestre Ledru
6723a54610
Merge pull request #2862 from rivy/fix.whitespace
refactor/polish ~ whitespace fixup
2022-01-11 17:51:37 +01:00
Terts Diepraam
f60c36f242
Merge pull request #2610 from miDeb/cp/abuse
cp: handle edge cases when dest is a symlink
2022-01-11 00:34:55 +01:00
Roy Ivy III
7a760cae99 refactor/polish ~ re-normalize whitespace
* minimize inconsistent/invisible whitespace

- consistent indentation (either spaces-only, tabs, *or* tabs with following spaces [for indentation])
- no internal/invisible tabs
- no trailing whitespace
- EOF EOLNs
2022-01-09 21:35:39 -06:00
Roy Ivy III
774e72551b change ~ relax 'nix' version and remove 'nix' patch
- code coverage compilation on MacOS latest (MacOS-11+) now works with newer 'nix' versions
2022-01-09 18:57:25 -06:00
Sylvestre Ledru
969f3cbf39
Merge pull request #2793 from tertsdiepraam/cksum-result-io-error
`cksum`: use `UIoError`
2022-01-07 21:47:01 +01:00
Terts Diepraam
7fa720d311 fix lint, fmt & udeps errors 2022-01-01 19:43:44 +01:00
Terts Diepraam
62341112df remove cut-specific macros 2022-01-01 18:50:34 +01:00
Terts Diepraam
c075f105a4 remove unnecessary and unused macros 2022-01-01 18:31:47 +01:00
Jeffrey Finkelstein
f2bf1a7ff7 fixes suggested by nightly version of clippy 2021-12-26 15:45:33 -05:00
Terts Diepraam
8885263ad5 cksum: use UIoError 2021-12-26 18:41:25 +01:00
Ryan Gonzalez
23c0734a62 uucore::fsext: Fix mountinfo parsing w/ multiple optional fields
proc(5) mentions the following for the fields section and hyphen:

> (7)  optional fields: zero or more fields of the form "tag[:value]";
> see below.
> (8)  separator: the end of the optional fields is marked by a single
> hyphen.

IOW, there may actually be multiple optional fields, not just one, in
which case the previously hardcoded indexes for the filesystem type and
device name are now incorrect. Now, the filesystem type and device name
are parsed relative to the hypen's location, ensuring that they will be
correct regardless of the number of optional fields.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2021-12-20 08:46:22 -06:00
Jan Verbeek
ceff2690d2 getgroups: Reuse buffer, add comment about performance 2021-11-26 14:48:34 +01:00
Jan Verbeek
b125159535 getgroups: Handle race conditions properly 2021-11-26 14:48:34 +01:00
Jan Verbeek
412a81e7bf uucore::entries: Remove unnecessary unsafe Vec operations 2021-11-26 14:48:33 +01:00
Jan Verbeek
f2ddae93fa uucore::entries: Make Passwd::locate and Group::locate thread-safe 2021-11-26 14:48:33 +01:00
Roy Ivy III
03e0cbb020 update 'nix' within workspace to force patched version 2021-11-19 17:55:03 -06:00
Sylvestre Ledru
6c6e047453
Merge pull request #2586 from Funky185540/docs/document-macros
macros: Add documentation with examples to macros
2021-11-19 21:50:38 +01:00
Sylvestre Ledru
b4416abc82
Merge pull request #2743 from thomasqueirozb/who_uresult
who: use UResult
2021-11-19 21:41:14 +01:00
Thomas Queiroz
235152a6b7
uucore/utmpx: remove unwrap in cannon_host
Default to hostname if getaddrinfo fails
2021-11-09 20:00:34 -03:00
Jan Verbeek
77e1570ea0 Move display::Quotable into its own crate
The standalone version has a number of bugfixes compared to the old
version.
2021-11-08 23:07:40 +01:00
Michael Debertol
bb35b0c37b uucore: add FileInformation 2021-11-01 22:38:44 +01:00
Thomas Queiroz
007f1b9f84
uu+tests: use strip_prefix and strip_suffix 2021-10-24 12:23:32 -03:00
Sylvestre Ledru
59e9870c56 Prepare version 0.0.8 2021-10-23 19:21:50 +02:00
James Robson
0b2483452a Add symbolic mode support to mkdir 2021-10-16 12:57:55 +01:00
Sylvestre Ledru
a0f538f2e8
Merge pull request #2679 from blyxxyz/uucore-inspection
uucore: Minor cleanup
2021-09-19 22:28:16 +02:00
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
Andreas Hartmann
89c6d32a20 backup_control: Refactor backup mode determination
Refactor the function that determines which backup mode to select based
on user input. It now complies with what the [GNU manual][1] specifies.

[1]: https://www.gnu.org/software/coreutils/manual/html_node/Backup-options.html
2021-07-05 12:44:40 +02:00
Andreas Hartmann
1309757d4d backup_control: Make utility functions private 2021-07-05 12:43:28 +02:00
Andreas Hartmann
fa0b4861b9 backup_control: Match abbreviated backup options
Add a function that takes a user-supplied backup option and checks if it
matches any of the valid backup options. This is because GNU allows to
abbreviate backup options, as long as they are valid and unambiguous.

In case a backup option is either invalid or ambiguous, an error type is
returned that contains a formatted error string for output to the user.
2021-07-05 12:43:28 +02:00
Andreas Hartmann
3b8f135842 backup_control: Add backup help string from GNU utils
The previous help string for the backup subroutines didn't comply with
the formatting found in the `--help` output of e.g. `mv` or `ln`.

Use the exact help string from these utilities instead.
2021-07-05 12:43:28 +02:00
Sylvestre Ledru
f2e12fee0a Silent buggy clippy warnings
Fails with:
```
error: use of irregular braces for `write!` macro
  --> src/uucore/src/lib/features/encoding.rs:19:17
   |
19 | #[derive(Debug, Error)]
   |                 ^^^^^
   |
   = note: `-D clippy::nonstandard-macro-braces` implied by `-D warnings`
help: consider writing `Error`
  --> src/uucore/src/lib/features/encoding.rs:19:17
   |
19 | #[derive(Debug, Error)]
   |                 ^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces
   = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
```
2021-07-04 19:06:37 +02:00
Sylvestre Ledru
ec1a301c56
Merge pull request #2473 from tertsdiepraam/usage-error
uucore: add usage errors
2021-07-04 11:46:07 +02:00
Sylvestre Ledru
d3652cc3c0
Merge pull request #2457 from Funky185540/install-implement-backup
install: implement --backup, -b and -S
2021-07-04 09:57:45 +02:00
Terts Diepraam
e46ce2947e add usage error 2021-07-02 19:31:16 +02:00
Terts Diepraam
6213a2a967
Merge pull request #2462 from miDeb/sort/version
sort/ls: implement version cmp matching GNU spec
2021-07-01 13:02:59 +02:00
Terts Diepraam
43bfec7170 uucore/error: add macros for standardized error handling 2021-06-28 13:49:45 +02:00
Terts Diepraam
66b1ac019d uucore/error: add standardized error handling (adds UResult & UError) 2021-06-28 13:49:35 +02:00
Andreas Hartmann
1a43a94e31 install: Apply rustfmt 2021-06-27 17:59:04 +02:00
Michael Debertol
233a778963 sort/ls: implement version cmp matching GNU spec
This reimplements version_cmp, which is used in sort and ls to sort
according to versions.
However, it is not bug-for-bug identical with GNU's implementation.
I reported a bug with GNU here:
https://lists.gnu.org/archive/html/bug-coreutils/2021-06/msg00045.html
This implementation does not contain the bugs regarding the handling of
file extensions and null bytes.
2021-06-27 15:29:17 +02:00
Andreas Hartmann
211af9a3ea backup_control: Add todo for gnu compliant behavior
The logic behind the file-backup implementation currently doesn't comply 100%
with what the GNU manual [1] describes. Adds a TODO so it isn't forgotten.

[1]: https://www.gnu.org/software/coreutils/manual/html_node/Backup-options.html
2021-06-26 00:27:08 +02:00
Jan Scheer
c0be979611 fix some issues with locale (replace "LANGUAGE" with "LC_ALL")
`LANGUAGE=C` is not enough, `LC_ALL=C` is needed as the environment
variable that overrides all the other localization settings.

e.g.
```bash
$ LANGUAGE=C id foobar
id: ‘foobar’: no such user

$ LC_ALL=C id foobar
id: 'foobar': no such user
```

* replace `LANGUAGE` with `LC_ALL` as environment variable in the tests
* fix the the date string of affected uutils
* replace `‘` and `’` with `'`
2021-06-23 11:30:28 +02:00
Roy Ivy III
b11e9a057e docs/spell ~ (uucore) add spelling exceptions 2021-06-19 18:37:13 -05:00
Terts Diepraam
de069190b9
Merge pull request #2417 from miDeb/sort/no-sigpipe-panic
sort: avoid sigpipe errors
2021-06-17 10:34:13 +02:00
Michael Debertol
b87387964d core: mute all BrokenPipe errors
On windows the error message does not contain `Broken pipe`, so let's
try to find the error `kind` which should be `BrokenPipe` in all cases.
2021-06-17 00:06:43 +02:00
Jan Scheer
996e1b8539 uucore/entries: fix getgrouplist wrapper to handle a bug in macOS's
`getgrouplist` implementation

* add documentation
2021-06-15 22:13:52 +02:00
Michael Debertol
a69c2d52f9 Merge branch 'master' of https://github.com/uutils/coreutils into timeout/cmd-args 2021-06-12 13:14:16 +02:00
Michael Debertol
a57313f01b core: represent signal values by their index 2021-06-12 13:12:15 +02:00
Terts Diepraam
8afc923796
Merge pull request #2237 from wfscheper/wfscheper/issue2118
chgrp: replace getopts with clap (#2118)
2021-06-12 11:20:24 +02:00
Jan Scheer
39f5f70f2b Merge branch 'master' into refactoring_parse_size 2021-06-12 02:24:07 +02:00
Jeong YunWon
e985131c83 uucore: remove unused warning of sort_groups 2021-06-11 23:26:58 +09:00
Jeong YunWon
fb67e54e20 uucore: clean up returning Err 2021-06-11 23:26:58 +09:00
Walter Scheper
cff75f242a chgrp: replace getopts with clap (#2118) 2021-06-10 16:38:44 -04:00
Michael Debertol
0f9bc8e974 timeout: disable timeout if it is set to zero 2021-06-10 21:24:43 +02:00
Michael Debertol
b0b937dc3e core: add signal name lookup by value 2021-06-10 21:24:43 +02:00
Michael Debertol
ceb5a2998c core: add EXIT signal
EXIT is supported by GNU (see 993ca832d2/lib/sig2str.c (L258)),
so we have to support it too to pass GNU tests.
2021-06-10 18:28:37 +02:00
Sylvestre Ledru
3e8c009a50
Merge pull request #2379 from youknowone/rotate
get_groups_gnu sort with rotate_right
2021-06-10 16:05:54 +02:00
Jeong YunWon
23f655e2a5
Use inclusive range
Co-authored-by: Michael Debertol <michael.debertol@gmail.com>
2021-06-10 11:15:01 +09:00
Sylvestre Ledru
393164f4a7
Merge pull request #2377 from tertsdiepraam/use-atty
`cat`/`cut`/`tty`/`nohup`: replace `is_std{in, out, err}_interactive` with atty
2021-06-09 22:42:56 +02:00
Jeong YunWon
cebf1f09df get_groups_gnu sort with rotate_right 2021-06-10 01:56:48 +09:00
Terts Diepraam
394eb82af1 cat/cut/tty/nohup: replace is_std{in, out, err}_interactive with atty 2021-06-09 17:12:03 +02:00
Jeong YunWon
f40f9fbf91 Fix build when not(feature = "process") 2021-06-09 23:51:04 +09:00
Jan Scheer
be8650278b Merge branch 'master' into refactoring_parse_size 2021-06-09 13:44:40 +02:00
Sylvestre Ledru
4471335609
Merge pull request #2360 from rivy/fix+rf
build and *lots* of clippy fixes
2021-06-08 22:06:11 +02:00
Jan Scheer
26ad05cbb4 uucore: fix order of group IDs returned from entries::get_groups()
As discussed here: https://github.com/uutils/coreutils/pull/2361
the group IDs returned for GNU's 'group' and GNU's 'id --groups'
starts with the effective group ID.
This implements a wrapper for `entris::get_groups()` which mimics
GNU's behaviour.

* add tests for `id`
* add tests for `groups`
* fix `id --groups --real` to no longer ignore `--real`
2021-06-08 18:39:05 +02:00
Roy Ivy III
f5e2daa056 refactor/uucore ~ fix cargo clippy complaint (clippy::needless_borrow) 2021-06-06 19:28:22 -05:00
Jan Scheer
f8e96150f8 fix clippy warnings and spelling
* add some missing LICENSE headers
2021-06-04 15:39:34 +02:00
Jan Scheer
130bf49e5d Merge branch 'master' of github.com:uutils/coreutils into refactoring_parse_size 2021-06-03 22:32:34 +02:00
Jan Scheer
ad26b7a042 head/tail/split: make error handling of NUM/SIZE arguments more
consistent

* add tests for each flag that takes NUM/SIZE arguments
* fix bug in tail where 'quiet' and 'verbose' flags did not override each other POSIX style
2021-06-03 20:37:29 +02:00
Jan Scheer
2f5f7c6fa1 split: use "parse_size" from uucore
* make stderr of parsing SIZE/NUMBER argument consistent with GNU's behavior
* add error handling
* add tests
2021-06-02 21:32:41 +02:00
Jan Scheer
a900c7421a od: use "parse_size" from uucore 2021-06-01 22:07:29 +02:00
Jan Scheer
cc659c8572 Merge branch 'master' of github.com:uutils/coreutils into refactoring_parse_size 2021-06-01 12:35:48 +02:00
Jan Scheer
a3e047ff16 uucore: add more tests to parse_size 2021-06-01 10:22:44 +02:00
Jan Scheer
8bf1e33b5d Merge branch 'master' of github.com:uutils/coreutils into refactoring_parse_size
* truncate: use "parse_size" from uucore
* workaround fix for "test_reference"
2021-05-31 19:11:06 +02:00
Roy Ivy III
3f35e0a421 refactor ~ cargo make format 2021-05-31 08:23:58 -05:00
Roy Ivy III
40e136d092 refactor/uucore ~ polish spelling (comments, names, and exceptions) 2021-05-31 08:23:57 -05:00
Roy Ivy III
48e509546a refactor/uucore ~ polish spelling (comments, names, and exceptions) 2021-05-31 08:11:31 -05:00
Jan Scheer
3a6605844f uucore: move 'parse_time' to 'parser'
"parse_time" only uses stdlib and does not need to be feature gated.
A more suitable place is the newly created "src/uucore/src/lib/parser/"
2021-05-31 09:54:31 +02:00
Jan Scheer
3aeccfd802 fix a lot of clippy warnings 2021-05-29 15:11:22 +02:00
Jan Scheer
a2947f6897 fix clippy warning 2021-05-29 00:46:25 +02:00
Jan Scheer
b1b3475e11 truncate: use "parse_size" from uucore 2021-05-28 22:21:03 +02:00
Jan Scheer
0c502f587b uucore: add new module "parse_size"
This adds a function to parse size strings, e.g. "2KiB" or "3MB".
It is based on similar functions used by head/tail/truncate, etc.
2021-05-28 22:20:31 +02:00
Terts Diepraam
658e52dde0
Merge pull request #2275 from blesson3/cp-backup-support
cp: implement backup support
2021-05-26 21:12:01 +02:00
Sylvestre Ledru
c08eae8e9a
Merge pull request #2276 from ycd/clear-macros
uucore: delete unused macros
2021-05-26 13:45:30 +02:00
Matt Blessed
7240b12895 uucore: implement backup control
Most of these changes were sourced from mv's existing backup control
implementation. A later commit will update the mv utility to use this
new share backup control.
2021-05-25 19:44:09 -04:00
Yağız can Değirmenci
898d2eb489 chore: delete 'error:' prefix on show_error 2021-05-26 02:32:02 +03:00
Yağız can Değirmenci
c78a7937f8 chore: delete show_info macro and replace with show_error 2021-05-26 02:27:10 +03:00
Yağız can Değirmenci
a77e92cc96 chore: delete unused macros 2021-05-26 01:53:40 +03:00
Jeffrey Finkelstein
bc9db289e8 head: add abstractions for "all but last n lines"
Add some abstractions to simplify the `rbuf_but_last_n_lines()`
function, which implements the "take all but the last `n` lines"
functionality of the `head` program. This commit adds

- `RingBuffer`, a fixed-size ring buffer,
- `ZLines`, an iterator over zero-terminated "lines",
- `TakeAllBut`, an iterator over all but the last `n` elements of an
  iterator.

These three together make the implementation of
`rbuf_but_last_n_lines()` concise.
2021-05-22 23:56:48 -04:00
Jeffrey Finkelstein
bee3b1237c uucore::fs: don't canonicalize last component
Change the behavior of `uucore::fs::canonicalize()` when `can_mode` is
`CanonicalizeMode::None` so that it does not attempt to resolve the
final component if it is a symbolic link. This matches the behavior of
the function for the non-final components of a path when `can_mode` is
`None`.
2021-05-22 11:18:16 -04:00
Sylvestre Ledru
4d3be19de3
Merge pull request #2240 from jhscheer/macos_test_coreutils
who/stat/pinky: adjust tests to be compatible with running on macOS
2021-05-22 12:39:05 +02:00
Jan Scheer
007e0a4e7f who/stat/pinky: adjust tests to be compatible with running on macOS
A lot of tests depend on GNU's coreutils to be installed in order
to obtain reference values during testing.
In these cases testing is limited to `target_os = linux`.
This PR installs GNU's coreutils on "github actions" and adjusts the
tests for `who`, `stat` and `pinky` in order to be compatible with macOS.

* `brew install coreutils` (prefix is 'g', e.g. `gwho`, `gstat`, etc.
* switch paths for testing to something that's available on both OSs,
    e.g. `/boot` -> `/bin`, etc.
* switch paths for testing to the macOS equivalent,
    e.g. `/dev/pts/ptmx` -> `/dev/ptmx`, etc.
* exclude paths when no equivalent is available,
    e.g. `/proc`, `/etc/fstab`, etc.
* refactor tests to make better use of the testing API
* fix a warning in utmpx.rs to print to stderr instead of stdout
* fix long_usage text in `who`
* fix minor output formatting in `stat`

* the `expected_result` function should be refactored
    to reduce duplicate code
* more tests should be adjusted to not only run on `target_os = linux`
2021-05-21 11:55:20 +02:00
Jan Scheer
8032c6d750 fix clippy warnings 2021-05-19 01:37:28 +02:00
Jan Scheer
a4fc2b5106 who: fix --lookup
This closes #2181.

`who --lookup` is failing with a runtime panic (double free).
Since `crate::dns-lookup` already includes a safe wrapper for `getaddrinfo`
I used this crate instead of further debugging the existing code in
utmpx::canon_host().

* It was neccessary to remove the version constraint for libc in uucore.
2021-05-13 22:16:15 +02:00
Jan Scheer
381f8dafc6 df/uucore: refactor - move duplicate code to uucore/fsext.rs 2021-05-10 23:37:01 +02:00
Jan Scheer
203ee463c7 stat/uucore: refactor - move fsext.rs to uucore 2021-05-10 10:46:00 +02:00
Jan Scheer
a885376583 uucore: refactor - reduce duplicate code related to fs::display_permissions
This is a refactor to reduce duplicate code, it affects chmod/ls/stat.
* merge `stat/src/fsext::pretty_access` into `uucore/src/lib/feature/fs::display_permissions_unix`
* move tests for `fs::display_permissions` from `test_stat::test_access` to `uucore/src/lib/features/fs::test_display_permissions`
* adjust `uu_chmod`, `uu_ls` and `uu_stat` to use `uucore::fs::display_permissions`
2021-05-08 11:52:41 +02:00
rethab
231bb7be93
Migrate mknod to clap, closes #2051 (#2056)
* mknod: add tests for fifo

* mknod: add test for character device
2021-05-05 22:59:40 +02:00
Rein F
a60fd07bc3
ls: improvements on time handling (#1986)
* ls: added creation time

* ls: Added most time features

Missing support for posix-,Format+, translating via locales. Also required more tests

* ls: rustfmt

* ls: Additional changes and fixes

Fixed the argument order, fixed a wrong iso format.

* ls: additional tests for styles

* ls: perfected arg parsing on time styles

* fix birthime test

* ls: Use 'stdout_str' in new tests

* ls: Disabled birthtime test for windows

* ls: removed indoc as a dependency

* ls: birthime test, sync first created file

* ls: birthime test, add comment explaining sync

* Removed ruby testfile birth_test.rb

This accidentally got commited in a merge
2021-04-28 20:54:27 +02:00
Christopher Regali
368e984fac
Change unchecked unwrapping to unwrap_or_default for Args-trait (#1845) (#1852)
* Change unchecked unwrapping to unwrap_or_default for argument parsing (resolving #1845)

* Added unit-testing for the collect_str function on invalid utf8 OsStrs

* Added a warning-message for identification purpose to the collect_str method.

* - Add removal of wrongly encoded empty strings to basename
- Add testing of broken encoding to basename
- Changed UCommand to use collect_str in args method to allow for integration testing of that method
- Change UCommand to use unwarp_or_default in arg method to match the behaviour of collect_str

* Trying out a new pattern for convert_str for getting a feeling of how the API feels with more control

* Adding convenience API for compact calls

* Add new API to everywhere, fix test for basename

* Added unit-testing for the conversion options

* Added unit-testing for the conversion options for windows

* fixed compilation and some merge hiccups

* Remove windows tests in order to make merge request build

* Fix formatting to match rustfmt for the merged file

* Improve documentation of the collect_str method and the unit-tests

* Fix compilation problems with test

Co-authored-by: Christopher Regali <chris.vdop@gmail.com>
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2021-04-25 23:28:42 +02:00