The default hex format, on x86(-64) prints 15 digits after the
decimal point, _but_ also trims trailing zeros, so it's not just
a simple default precision and a little bit of extra handling is
required.
Also add a bunch of tests.
Fixes#7364.
When parsing integers, we should still return the min/max value
of the type (depending on the type), and wrap that in the error.
We need to refactor the map function to handle this case better,
and add an extract function to get the value out of an error
(if any).
This fixes the integer part of #7508.
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.