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

Exclude - from user-supplied OPTSPEC for short options #25

Closed
UrsaDK opened this issue Dec 11, 2024 · 1 comment
Closed

Exclude - from user-supplied OPTSPEC for short options #25

UrsaDK opened this issue Dec 11, 2024 · 1 comment

Comments

@UrsaDK
Copy link
Owner

UrsaDK commented Dec 11, 2024

[A followup from #14]

To enable support for long options via the built-in getopts, OPTSPEC is extended with -:. However, since the built-in getopts processes OPTSPEC characters from right to left, there’s a risk that - could be redefined by the user, leading to two scenarios:

  • If the user’s OPTSPEC defines -: (a dash followed by an argument), the current behavior for - is duplicated, and getopts_long works as intended.

  • If the user’s OPTSPEC defines - (a dash without an argument), it overrides getopts_long’s definition (-:). This causes long options (e.g., --test) to be interpreted as a series of short options (-, t, e, s), which is definitely not the intended behavior.

The simplest solution to avoid this, is to ensure that user-supplied OPTSPEC for short options does not include the - character, and raise an error/warning if it does.

@UrsaDK
Copy link
Owner Author

UrsaDK commented Dec 14, 2024

Implemented as part #28 in this commit – 80eb03a

@UrsaDK UrsaDK closed this as completed Dec 14, 2024
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

No branches or pull requests

1 participant