install_system_commands(pre = "sys_")
public
CommandProcessor.install_system_commands(pre)
pre: String - command name prefix
defines every command which belongs in default_system_path via
CommandProcessor.command(). It doesn’t define already defined methods
twice. By default, “pre_” is prefixes to each method name. Characters
that may not be used in a method name are all converted to ‘_’.
Definition errors are just ignored.
Show source
def self.install_system_commands(pre = "sys_")
defined_meth = {}
for m in Shell.methods
defined_meth[m] = true
end
sh = Shell.new
for path in Shell.default_system_path
next unless sh.directory? path
sh.cd path
sh.foreach do
|cn|
if !defined_meth[pre + cn] && sh.file?(cn) && sh.executable?(cn)
command = (pre + cn).gsub(/\W/, "_").sub(/^([0-9])/, '_\1')
begin
def_system_command(command, sh.expand_path(cn))
rescue
Shell.notify "warn: Can't define #{command} path: #{cn}"
end
defined_meth[command] = command
end
end
end
end