diff --git a/IPython/utils/path.py b/IPython/utils/path.py index 82175ae..137f930 100644 --- a/IPython/utils/path.py +++ b/IPython/utils/path.py @@ -358,9 +358,11 @@ def expand_path(s): def unescape_glob(string): """Unescape glob pattern in `string`.""" - for pattern in '*[]!?': - string = string.replace(r'\{0}'.format(pattern), pattern) - return string + def unescape(s): + for pattern in '*[]!?': + s = s.replace(r'\{0}'.format(pattern), pattern) + return s + return '\\'.join(map(unescape, string.split('\\\\'))) def shellglob(args): diff --git a/IPython/utils/tests/test_path.py b/IPython/utils/tests/test_path.py index f44b1a6..f5c6d52 100644 --- a/IPython/utils/tests/test_path.py +++ b/IPython/utils/tests/test_path.py @@ -486,3 +486,7 @@ def test_shellglob(): def test_unescape_glob(): nt.assert_equals(path.unescape_glob(r'\*\[\!\]\?'), '*[!]?') + nt.assert_equals(path.unescape_glob(r'\\*'), r'\*') + nt.assert_equals(path.unescape_glob(r'\\\*'), r'\*') + nt.assert_equals(path.unescape_glob(r'\\a'), r'\a') + nt.assert_equals(path.unescape_glob(r'\a'), r'\a')