Commit graph

196 commits

Author SHA1 Message Date
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
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
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
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
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
Sylvestre Ledru
8ccc6ade61
Merge branch 'master' into split-wsl-detection 2021-04-24 10:24:13 +02:00
Andrew Rowson
d0c7e8c09e
du error output should match GNU (#1776)
* du error output should match GNU

* Created a new error macro which allows the customization of the
  "error:" string part
* Match the du output based on the type of error encountered. Can extend
  to handling other errors I guess.

* Rustfmt updates

* Added non-windows test for du no permission output
2021-04-17 10:26:52 +02:00
Sylvestre Ledru
fc057b816b
Merge branch 'master' into split-wsl-detection 2021-04-17 10:22:54 +02:00
Reto Hablützel
d67560c37a fix clippy for unix 2021-04-11 16:34:19 +02:00
Sylvestre Ledru
45d70b0c98
Merge pull request #2033 from Gilnaa/panic_2021
Fixed panic!/assert! used with improper format strings
2021-04-06 13:46:07 +02:00
Gilad Naaman
bc426fb3af Fixed panic!/assert! used with improper format strings 2021-04-06 14:23:54 +03:00
ReggaeMuffin
b1fcb621a8
wsl2: wsl no longer differs in output
refactor `is_wsl` to `is_wsl_1` and `is_wsl_2`

On my tests with wsl2 ubuntu2004 all tests pass without special cases

I moved wsl detection into uucore so that it can be shared instead of duplicated

I moved `parse_mode` into uucode as it seemed to fit there better and anyway requires libc feature
2021-04-06 10:58:49 +01:00
Marvin Hofmann
9581fcf688
rm: add verbose output and trim multiple slashes (#1988)
* rm: add verbose output and trim multiple slashes

Uses the normalize_path used in cargo to strip duplicate slashes
With a link to a std rfc https://github.com/rust-lang/rfcs/issues/2208

This fixes https://github.com/uutils/coreutils/issues/1829

This also touches https://github.com/uutils/coreutils/issues/1768 
but does not attempt to fully solve it
2021-04-05 22:18:47 +02:00
Sylvestre Ledru
ac031dffa4 new release 0.0.5 2021-04-03 10:30:07 +02:00
Neculai Balaban
93c7cbe65e documentation for usual macros
- removed repeat_str helper as it's now part of std
- added docstrings for usual macros and test utils
2021-03-22 12:13:38 +02:00
aspen
4e29b693f8
uutils: change every target_os = "macos" to target_vendor = "apple" 2021-03-18 08:42:53 -04:00
Daniel Rocco
0e02607dc7 numfmt: implement --field 2021-03-08 10:53:34 -05:00
Sylvestre Ledru
8772d81236 Update to platform-info 0.1 2021-03-07 11:29:38 +01:00
Sylvestre Ledru
6481c5a247 Prepare version 0.0.4 2021-03-07 11:29:38 +01:00
Chad Brewbaker
bb54669a5d
Fix macOS aarch64 compile errors (#1724) 2021-02-23 10:25:06 +01:00