X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?p=spider.git;a=blobdiff_plain;f=perl%2FDXCommandmode.pm;h=5348212d620ceb7c09626f5c9d7f56ef3d5690a8;hp=024ccb0e491ece4cac8962e9cdb0efbfd241f36c;hb=6a0068ec3df1dca0c6ae2714af3c0a4a62998dcf;hpb=3f145290a93b39bf15b50269dd8be585d7b4bc9c diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 024ccb0e..5348212d 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -17,15 +17,18 @@ use DXUser; use DXVars; use DXDebug; use DXM; +use CmdAlias; use FileHandle; use Carp; use strict; -use vars qw(%Cache %cmd_cache $errstr); +use vars qw(%Cache %cmd_cache $errstr %aliases); %Cache = (); # cache of dynamically loaded routine's mod times %cmd_cache = (); # cache of short names $errstr = (); # error string from eval +%aliases = (); # aliases for (parts of) commands + # # obtain a new connection this is derived from dxchannel # @@ -109,6 +112,12 @@ sub normal if ($cmd) { my ($path, $fcmd); + + # alias it if possible + my $acmd = CmdAlias::get_cmd($cmd); + if ($acmd) { + ($cmd, $args) = "$acmd $args" =~ /^([\w\/]+)\s*(.*)/o; + } # first expand out the entry to a command ($path, $fcmd) = search($main::localcmd, $cmd, "pl"); @@ -386,9 +395,8 @@ sub find_cmd_name { if (!open $fh, $filename) { $errstr = "Syserr: can't open '$filename' $!"; }; - my $old = $fh->input_record_separator(undef); + local $/ = undef; my $sub = <$fh>; - $fh->input_record_separator($old); close $fh; #wrap the code into a subroutine inside our unique package