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

handle braces escapes only #2

Open
drslump opened this issue Jul 26, 2018 · 0 comments
Open

handle braces escapes only #2

drslump opened this issue Jul 26, 2018 · 0 comments

Comments

@drslump
Copy link

drslump commented Jul 26, 2018

Since brace expansion usually happens before other expansions (i.e. glob), the current behaviour of handling all the escaped characters breaks later stages. For instance:

>>> braceexpand(r'{foo,bar}-\?')
['foo-?', 'bar-?']   # lost the information about the escaped "?"

I think it'll be best if escape handling only removed the backslash if it refers to a brace character, otherwise they're left in the expansions to avoid the information loss.

Since this would be a breaking change I guess the escape keyword arg could accept also 'preserve' to enable this mode?

Right now I'm working around it by double-escaping the string before feeding it to braceexpand:

>>> value = re.sub(r'\\([^{}])', r'\\\\\1', value)
>>> braceexpand(value)

But the approach is finicky since it only handles braces and won't work with something like {1\..5\,x}.

thanks for this great module!

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