def alias(self, argv):
        """alias [newalias]
    With no argument prints the current set of aliases. With an argument of the
    form alias ..., sets a new alias.  """
        if len(argv) == 1:
            for name, val in self._aliases.items():
                self._print("alias %s='%s'" % (name, " ".join(val)))
            return 0
        elif len(argv) == 2 and '=' not in argv[1]:
            name = argv[1]
            try:
                self._print("%s=%s" % (name, " ".join(self._aliases[name])))
            except __HOLE__:
                self._print("undefined alias.")
            return 0
        # else
        try: # this icky code to handle different permutations of where the '=' is.
            argv.pop(0) # discard 'alias'
            name = argv.pop(0)
            if "=" in name:
                name, rh = name.split("=", 1)
                argv.insert(0,rh)
            elif argv[0].startswith("="):
                if len(argv[0]) > 1: # if argv[1] is '=something'
                    argv[0] = argv[0][1:]
                else:
                    del argv[0] # remove the '='
            self._aliases[name] = argv
        except:
            ex, val = sys.exc_info()[:2]
            self._print("alias: Could not set alias. Usage: alias name=value")
            self._print("%s (%s)" % (ex, val))
            return 1
dataset/ETHPy150Open kdart/pycopia/fepy/pycopia/fepy/CLI.py/BaseCommands.alias