517 args = pycompat.shlexsplit(cmd) |
517 args = pycompat.shlexsplit(cmd) |
518 return args + givenargs |
518 return args + givenargs |
519 |
519 |
520 |
520 |
521 def aliasinterpolate(name, args, cmd): |
521 def aliasinterpolate(name, args, cmd): |
522 '''interpolate args into cmd for shell aliases |
522 """interpolate args into cmd for shell aliases |
523 |
523 |
524 This also handles $0, $@ and "$@". |
524 This also handles $0, $@ and "$@". |
525 ''' |
525 """ |
526 # util.interpolate can't deal with "$@" (with quotes) because it's only |
526 # util.interpolate can't deal with "$@" (with quotes) because it's only |
527 # built to match prefix + patterns. |
527 # built to match prefix + patterns. |
528 replacemap = {b'$%d' % (i + 1): arg for i, arg in enumerate(args)} |
528 replacemap = {b'$%d' % (i + 1): arg for i, arg in enumerate(args)} |
529 replacemap[b'$0'] = name |
529 replacemap[b'$0'] = name |
530 replacemap[b'$$'] = b'$' |
530 replacemap[b'$$'] = b'$' |
628 self._populatehelp(ui, name, cmd, self.fn, cmdhelp) |
628 self._populatehelp(ui, name, cmd, self.fn, cmdhelp) |
629 |
629 |
630 except error.UnknownCommand: |
630 except error.UnknownCommand: |
631 self.badalias = _( |
631 self.badalias = _( |
632 b"alias '%s' resolves to unknown command '%s'" |
632 b"alias '%s' resolves to unknown command '%s'" |
633 ) % (self.name, cmd,) |
633 ) % ( |
|
634 self.name, |
|
635 cmd, |
|
636 ) |
634 self.unknowncmd = True |
637 self.unknowncmd = True |
635 except error.AmbiguousCommand: |
638 except error.AmbiguousCommand: |
636 self.badalias = _( |
639 self.badalias = _( |
637 b"alias '%s' resolves to ambiguous command '%s'" |
640 b"alias '%s' resolves to ambiguous command '%s'" |
638 ) % (self.name, cmd,) |
641 ) % ( |
|
642 self.name, |
|
643 cmd, |
|
644 ) |
639 |
645 |
640 def _populatehelp(self, ui, name, cmd, fn, defaulthelp=None): |
646 def _populatehelp(self, ui, name, cmd, fn, defaulthelp=None): |
641 # confine strings to be passed to i18n.gettext() |
647 # confine strings to be passed to i18n.gettext() |
642 cfg = {} |
648 cfg = {} |
643 for k in (b'doc', b'help', b'category'): |
649 for k in (b'doc', b'help', b'category'): |