Repository navigation
tail: honor _POSIX2_VERSION for bare -c and +NUM obsolete forms - #15529
emirmrkaljevic wants to merge 2 commits into
Conversation
|
GNU testsuite comparison: |
| use uucore::parser::parse_size::ParseSizeError; | ||
| use uucore::parser::parse_time; | ||
| use uucore::parser::shortcut_value_parser::ShortcutValueParser; | ||
| use uucore::posix::{MODERN, TRADITIONAL, posix_version}; |
There was a problem hiding this comment.
could you please also drop tail (TBD) from the list in src/uucore/src/lib/mods/posix.rs? :)
| } | ||
|
|
||
| pub fn parse_obsolete(arg: &OsString, input: Option<&OsString>) -> UResult<Option<Settings>> { | ||
| let posix = posix_version(); |
There was a problem hiding this comment.
did you run the GNU tail tests too? tail.pl has a few _POSIX2_VERSION cases
setup: git clone https://github.com/coreutils/coreutils.git ../gnu
run: bash util/build-gnu.sh && bash util/run-gnu-test.sh tests/tail/tail.pl
|
Thanks! I removed the "(TBD)" marker for tail in |
Merging this PR will degrade performance by 15.86%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | true_consecutive_calls |
294.7 ns | 350.2 ns | -15.86% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing emirmrkaljevic:tail-c-missing-count (319958a) with main (5fda18e)2
Footnotes
-
70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
main(b77b664) during the generation of this report, so 5fda18e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
Summary
tail -c(no count) was read as the obsolete form and printed the last 10 bytes. GNU only does that under POSIX 1992 (_POSIX2_VERSIONbelow 200112); otherwise-cneeds a value. Now-calone falls back to the normal "a value is required" error unless_POSIX2_VERSIONselects POSIX 1992.+NUMform, so with_POSIX2_VERSIONin 200112..200809 an argument like+2is now a file name, as in GNU. The default and200809/199209keep reading+NUMas before.Both checks use the existing
uucore::posixhelpers (likesortanduniq) and sit inparse_obsolete, before the obsolete parser runs.Fixes #15528
Test plan
test_tail_obsolete_bare_c_needs_posix_1992andtest_tail_obsolete_plus_is_a_file_under_posix_2001; both fail without the changecargo test --no-default-features --features tail test_tail::: 174 passed, 12 ignored;cargo test -p uu_tail --lib: 38 passedcargo fmt --check,cargo clippy -p uu_tail --all-targets -- -D warnings-c,-b,-l,-,+,+c,+5,-5c,+3c,+2 FILE,-c 3,-n 2with no_POSIX2_VERSIONand with 199209, 200112 and 200809 (only-c 3under 199209 differs, see the issue)Found with behave.