Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basename: Fix handling of repeated flags/arguments #6018

Merged
merged 2 commits into from
Feb 27, 2024

Conversation

BenWiederhake
Copy link
Collaborator

This fixes several GNU behavior bugs around repeated arguments. In my eyes, the parsing code is now simpler, too.

Note in particular that args_override_self would NOT work here, since it would in all cases cause options::NAME to override itself, or interfere with trailing_var_arg.

This fixes #5998 for the special case of basename.

Notes on the GNU documentation bug

The GNU basename help suggests that -z immediately implies "multi-name mode", because it cannot appear in the first pattern:

$ basename --help
Usage: basename NAME [SUFFIX]
  or:  basename OPTION... NAME...

However, that is evidently wrong:

$ basename -z tool l  | hd
00000000  74 6f 6f 00                                       |too.|
00000004

If -z would imply multi-name mode, this should have interpreted l as a second file name, but it was obviously parsed as the suffix-to-be-removed.

Hence a bug in the --help string. And that's why I also changed our basename.md.

Note in particular that `args_override_self` would *NOT* work here,
since it would in all cases cause `options::NAME` to override itself,
or interfere with `trailing_var_arg`.
@BenWiederhake
Copy link
Collaborator Author

CI errors are only flakes:

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

Would you like to fix that upstream? I can do it if you want

@BenWiederhake
Copy link
Collaborator Author

The documentation issue? That sounds fantastic, yes please! :)

@cakebaker cakebaker merged commit 8b2a292 into uutils:main Feb 27, 2024
60 of 62 checks passed
@cakebaker
Copy link
Contributor

Good job, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow repeated flags much more often
3 participants