It's not totally clear why they sometimes work, sometimes fail,
but it does appear that running `stat` on `/dev/stdin` is perhaps
not the most reliable approach.
A likely more solid approach is described in #7583.
* Fixes#7558 Added check to only insert addition double hyphen if at start of arguments to correctly prepend addition hyphens for clap as well as additional test case
* additional comment
* fixes issue where flags precedes "--" as arguments
Fixes issue #7472.
Update to head app when printing all-but-last-n-lines of a file.
Code now checks if the last line of the input file is missing a terminating
newline character, and if so prints an extra line.
This aligns with GNU-head behavior.
Also improved performance of this usecase by using an optimized iterator
(memchr-iter) for searching through the input file.
I found the logic a little difficult to understand, and the
comment probably doesn't match what `-N` is supposed to do?
Intead, let's just manually set mtime and atime.
Hopefully this helps clear up Android flakiness in #7570. Or at
least understand better what is going on.
See #7542, it's not totally clear where the problem comes from,
but blanking LD_PRELOAD set by termux seems to fix the problem
(but introduces other issues.
Let's just disable these tests for now.
For some unclear reason, Android _now_ sometimes returns an
IsADirectory error, instead of PermissionDenied, when trying
to execute `.`.
Since this test really wants to test PermissionDenied, we try
to execute a file in the fixture instead, that doesn't have
exec permission.
Also, limit this test to Unix.
Fixes part of #7542.
Some of these tests are not completely defined behavior, but
in many cases they make sense (or at least one can find some
consistent logic to it).
However, there are 2 edge cases that are more dubious IMHO.
One of them has been reported on list a while back, and I
just reported another.
Tests for both `seq` and `yes` run a command that never terminates,
and check the beggining of their output in stdout, move the copied
parts of the wrapper function to common/util.
We still need to use slightly different logic to parse exit value
as `seq` returns success if stdout gets closed, while `yes` fails.
* Add test to ensure arch output is not empty
This test ensures that the output of the arch command is non-empty, which is a minimal expectation across all supported architectures.
This helps avoid regressions or edge cases where the command might unexpectedly return an empty string on unsupported or misconfigured platforms.
* Update tests/by-util/test_arch.rs
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Apply cargo fmt formatting
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* Create failing test for #7455
Also update existing test to ensure output is empty.
* add ignore until relevant issue is fixed
---------
Co-authored-by: M Bussonnier <mbussonnier@gmail.com>
- shuf now uses OS strings, so it can read from filenames that are
invalid Unicode and it can shuffle arguments that are invalid
Unicode. `uucore` now has an `OsWrite` trait to support this without
platform-specific boilerplate.
- shuf no longer tries to split individual command line arguments,
only bulk input from a file/stdin. (This matches GNU and busybox.)
- More values are parsed inside clap instead of manually, leading to
better error messages and less code.
- Some code has been simplified or made more idiomatic.
When using `touch -t` with a 2 digit year, the year is interpreted as
a relative year to 2000.
When the year is 68 or less, it should be interpreted as 20xx.
When the year is 69 or more, it should be interpreted as 19xx.
This is the behavior of GNU `touch`.
fixes gh-7280
Arguably 2 digits years should be deprecated as we
are already closer to 2069, than 1969.