Skip to content

Commit

Permalink
options: fix pathological spacing issues with regex
Browse files Browse the repository at this point in the history
  • Loading branch information
theWorstComrade authored and idank committed Dec 29, 2021
1 parent ebc5e9f commit d35f949
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions explainshell/options.py
Expand Up @@ -23,9 +23,9 @@ def extract(manpage):
opt_regex = re.compile(r'''
(?P<opt>--?(?:\?|\#|(?:\w+-)*\w+)) # option starts with - or -- and can have - in the middle but not at the end, also allow '-?'
(?:
(?:\s*(=)?\s*) # -a=
(?:\s?(=)?\s?) # -a=
(?P<argoptional>[<\[])? # -a=< or -a=[
(?:\s*(=)?\s*) # or maybe -a<=
(?:\s?(=)?\s?) # or maybe -a<=
(?P<arg>
(?(argoptional) # if we think we have an arg (we saw [ or <)
[^\]>]+ # either read everything until the closing ] or >
Expand All @@ -39,7 +39,7 @@ def extract(manpage):
)
(?(argoptional)(?P<argoptionalc>[\]>])) # read closing ] or > if we have an arg
)? # the whole arg thing is optional
(?P<ending>,\s*|\s+|\Z|/|\|)''', re.X) # read any trailing whitespace or the end of the string
(?P<ending>,\s*|\s+|\Z|/|\|)''', re.X) # read any trailing whitespace or the end of the string

opt2_regex = re.compile(r'''
(?P<opt>\w+) # an option that doesn't start with any of the usual characters, e.g. options from 'dd' like bs=BYTES
Expand Down

0 comments on commit d35f949

Please sign in to comment.