Commit cb2ddfbc authored by Keegi's avatar Keegi

Prevent overwriting built-in commands with aliases, as it would delete access...

Prevent overwriting built-in commands with aliases, as it would delete access to the built-in command permanently
parent d2c1b08e
...@@ -99,6 +99,9 @@ class pronsole(cmd.Cmd): ...@@ -99,6 +99,9 @@ class pronsole(cmd.Cmd):
print "Alias '"+alias_name+"' is not defined" print "Alias '"+alias_name+"' is not defined"
return return
# (re)define an alias # (re)define an alias
if alias_name not in self.aliases.keys() and hasattr(self.__class__,"do_"+alias_name):
print "Name '"+alias_name+"' is already being used by built-in command"
return
func = lambda self,args,alias_def=alias_def: self.onecmd(" ".join((alias_def,args))) func = lambda self,args,alias_def=alias_def: self.onecmd(" ".join((alias_def,args)))
self.aliases[alias_name] = alias_def self.aliases[alias_name] = alias_def
setattr(self.__class__,"do_"+alias_name,func) setattr(self.__class__,"do_"+alias_name,func)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment