You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
[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.The text was updated successfully, but these errors were encountered: