Commits

Anonymous committed 9d94bc2

0.13dev: Merged from 0.12-stable.

  • Participants
  • Parent commits 503506e
  • Branches trunk

Comments (0)

Files changed (3)

trac/admin/api.py

     def complete(self, text):
         return list(set(a for a in self if a.startswith(text)))
 
-        
+
+def path_startswith(path, prefix):
+    return os.path.normcase(path).startswith(os.path.normcase(prefix))
+
+
 class PathList(list):
     """A list of paths for command argument auto-completion."""
     def complete(self, text):
         """Return the items in the list matching text."""
-        matches = list(set(a for a in self if a.startswith(text)))
+        matches = list(set(a for a in self if path_startswith(a, text)))
         if len(matches) == 1 and not os.path.isdir(matches[0]):
             matches[0] += ' '
         return matches
     except OSError:
         return result
     for entry in dlist:
-        path = os.path.join(dname, entry)
+        path = os.path.normpath(os.path.join(dname, entry))
         try:
             if os.path.isdir(path):
                 result.append(os.path.join(path, ''))

trac/admin/console.py

 import locale
 import os.path
 import pkg_resources
-import shlex
+from shlex import shlex
 import StringIO
 import sys
 import traceback
         try:
             import readline
             delims = readline.get_completer_delims()
-            for c in '-/:()':
+            for c in '-/:()\\':
                 delims = delims.replace(c, '')
             readline.set_completer_delims(delims)
             
 
         ... but shlex is not unicode friendly.
         """
-        return [unicode(token, 'utf-8')
-                for token in shlex.split(argstr.encode('utf-8'))] or ['']
+        lex = shlex(argstr.encode('utf-8'), posix=True)
+        lex.whitespace_split = True
+        lex.commenters = ''
+        if os.name == 'nt':
+            lex.escape = ''
+        return [unicode(token, 'utf-8') for token in lex] or ['']
 
     def word_complete(self, text, words):
         words = list(set(a for a in words if a.startswith(text)))

trac/admin/tests/console.py

 import trac.timeline.web_ui
 import trac.wiki.web_ui
 
-
 from trac.admin import console, console_date_format
 from trac.config import Configuration
 from trac.db import DatabaseManager