-import os
import glob
+import os
+import re
import stat
+BACKSLASH_ESCAPE_RE = re.compile(r'\\(.)')
+
class SubstitutionError(Exception):
pass
def sub_glob(v):
l = glob.glob(v)
if len(l) == 0:
- raise SubstitutionError("$(glob {}) no match fonud".format(v))
+ raise SubstitutionError("$(glob {}) no match found".format(v))
else:
return l[0]
while True:
m = search(c)
if m is None:
- return c
+ return BACKSLASH_ESCAPE_RE.sub(r'\1', c)
v = do_substitution(p, c[m[0]+2 : m[1]])
var = True