~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shell.py

  • Committer: Aaron Bentley
  • Date: 2005-10-27 14:26:09 UTC
  • Revision ID: abentley@panoramicfeedback.com-20051027142609-c6fdf66ac5b86dc4
Prevented bzr's rm and ls from being invoked in the shell

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from bzrlib.errors import BzrError
25
25
from bzrlib.commands import get_cmd_object, get_all_cmds
26
26
 
 
27
SHELL_BLACKLIST = set(['rm', 'ls'])
 
28
 
 
29
class BlackListedCommand(BzrError):
 
30
    def __init__(self, command):
 
31
        BzrError.__init__(self, "The command %s is blacklisted for shell use" %
 
32
                          command)
 
33
 
27
34
class PromptCmd(cmd.Cmd):
28
35
    def __init__(self):
29
36
        cmd.Cmd.__init__(self)
110
117
        args = line.split()
111
118
        commandname = args.pop(0)
112
119
        try:
 
120
            if commandname in SHELL_BLACKLIST:
 
121
                raise BlackListedCommand(commandname)
113
122
            cmd_obj = get_cmd_object(commandname)
114
 
        except BzrError:
 
123
        except (BlackListedCommand, BzrError):
115
124
            return os.system(line)
116
125
 
117
126