Added new pipe syntax to check for recursive aliases.

This commit is contained in:
Jeremy Fincher 2003-09-10 08:15:44 +00:00
parent e0fae30f46
commit ffefdf1ab7
2 changed files with 4 additions and 1 deletions

View File

@ -93,7 +93,8 @@ class RecursiveAlias(Exception):
pass pass
def findAliasCommand(s, alias): def findAliasCommand(s, alias):
r = re.compile(r'(^|\[)\s*%s' % re.escape(s)) s = re.escape(s)
r = re.compile(r'(?:(^|\[)\s*%s|\|\s*%s)' % (s, s))
return bool(r.search(alias)) return bool(r.search(alias))
dollarRe = re.compile(r'\$(\d+)') dollarRe = re.compile(r'\$(\d+)')

View File

@ -47,6 +47,8 @@ class FunctionsTest(unittest.TestCase):
self.failUnless(Alias.findAliasCommand(s, '[ %s]' % s)) self.failUnless(Alias.findAliasCommand(s, '[ %s]' % s))
self.failUnless(Alias.findAliasCommand(s, 'foo bar [%s]' % s)) self.failUnless(Alias.findAliasCommand(s, 'foo bar [%s]' % s))
self.failUnless(Alias.findAliasCommand(s, 'foo bar [ %s]' % s)) self.failUnless(Alias.findAliasCommand(s, 'foo bar [ %s]' % s))
self.failUnless(Alias.findAliasCommand(s, 'foo | %s' % s))
self.failUnless(Alias.findAliasCommand(s, 'foo |%s' % s))
def testFindBiggestDollar(self): def testFindBiggestDollar(self):
self.assertEqual(Alias.findBiggestDollar(''), None) self.assertEqual(Alias.findBiggestDollar(''), None)