~benoit.pierre/bzrtools/shell_improvements

« back to all changes in this revision

Viewing changes to shell.py

  • Committer: Benoît Pierre
  • Date: 2008-11-30 16:44:26 UTC
  • Revision ID: benoit.pierre@gmail.com-20081130164426-briko2n96pvtxkbs
Fix shell handling of alias so for example "s|grep pattern" correctly
works if s is an alias.

Show diffs side-by-side

added added

removed removed

Lines of Context:
184
184
 
185
185
    def default(self, line):
186
186
        args = shlex.split(line)
187
 
        alias_args = get_alias(args[0])
188
 
        if alias_args is not None:
189
 
            args[0] = alias_args.pop(0)
 
187
        alias_args = None
190
188
 
191
189
        commandname = args.pop(0)
192
 
        for char in ('|', '<', '>'):
 
190
        for char in COMPLEX_COMMAND_CHARS:
193
191
            commandname = commandname.split(char)[0]
194
 
        if commandname[-1] in ('|', '<', '>'):
 
192
        if commandname[-1] in COMPLEX_COMMAND_CHARS:
195
193
            commandname = commandname[:-1]
196
194
        try:
 
195
            alias_args = get_alias(commandname)
 
196
            if alias_args is not None:
 
197
                commandname = alias_args.pop(0)
197
198
            if commandname in SHELL_BLACKLIST:
198
199
                raise BlackListedCommand(commandname)
199
200
            cmd_obj = get_cmd_object(commandname)