fixed problem caused by moving the command execution into a separate
authordjk <djk>
Mon, 30 Nov 1998 13:42:22 +0000 (13:42 +0000)
committerdjk <djk>
Mon, 30 Nov 1998 13:42:22 +0000 (13:42 +0000)
function with read (and using state changes with stored functions)
fixed typo in sh/st

cmd/show/station.pl
perl/DXCommandmode.pm
perl/client.pl

index 6c78f45ce16ddde6f19c4fbf4e964530e0856f9b..0f2140337ec95939b9f64308004da491d127ec84 100644 (file)
@@ -20,7 +20,7 @@ if (@f == 0) {
        my $sort = $ref->sort;
        my $qth = $ref->qth;
        my $home = $ref->node;
-    push @out, "$call $sort $qth $node";
+    push @out, "$call $sort $qth $home";
   }
 } else {
   foreach $call (@f) {
index 84d809fd257e730e30ed388dd324be25e3d93665..4f0566f9ebc2f5f4f322d5db6d4d9b8e566cd1b6 100644 (file)
@@ -97,7 +97,14 @@ sub normal
        # remove leading and trailing spaces
        $cmdline =~ s/^\s*(.*)\s*$/$1/;
        
-       if ($self->{state} eq 'prompt') {
+       if ($self->{func}) {
+               my $c = qq{ \@ans = $self->{func}(\$self, \$cmdline) };
+               dbg('eval', "stored func cmd = $c\n");
+               eval  $c;
+               if ($@) {
+                       return (1, "Syserr: Eval err $errstr on stored func $self->{func}");
+               }
+       } elsif ($self->{state} eq 'prompt') {
                @ans = run_cmd($self, $cmdline) if length $cmdline;
        
                if ($self->{pagelth} && @ans > $self->{pagelth}) {
@@ -141,7 +148,7 @@ sub normal
                } else {
                        $self->state('prompt');
                }
-       }
+       } 
        
        # send a prompt only if we are in a prompt state
        $self->prompt() if $self->{state} =~ /^prompt/o;
@@ -154,73 +161,57 @@ sub normal
 
 sub run_cmd
 {
-  my $self = shift;
-  my $user = $self->{user};
-  my $call = $self->{call};
-  my $cmdline = shift;
-  my @ans;
-
-  # are we in stored state?
-  if ($self->{func}) {
-    my $c = qq{ \@ans = $self->{func}(\$self, \$cmdline) };
-    dbg('eval', "stored func cmd = $c\n");
-    eval  $c;
-    if ($@) {
-      return (1, "Syserr: Eval err $errstr on stored func $self->{func}");
-    }
-  } else {
-
-    # special case only \n input => " "
-#    if ($cmdline eq " ") {
-#        $self->prompt();
-#        return;
-#      }
+       my $self = shift;
+       my $user = $self->{user};
+       my $call = $self->{call};
+       my $cmdline = shift;
+       my @ans;
+       
        
     # strip out //
     $cmdline =~ s|//|/|og;
-  
+       
     # split the command line up into parts, the first part is the command
     my ($cmd, $args) = $cmdline =~ /^([\w\/]+)\s*(.*)/o;
-
+       
     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");
-         ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
-
-      my $package = find_cmd_name($path, $fcmd);
-         @ans = (0) if !$package ;
-
-      if ($package) {
-           my $c = qq{ \@ans = $package(\$self, \$args) };
-           dbg('eval', "cluster cmd = $c\n");
-           eval  $c;
-           if ($@) {
-                 @ans = (0, "Syserr: Eval err cached $package\n$@");
-        }
-         }
+               
+               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");
+               ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd;
+               
+               my $package = find_cmd_name($path, $fcmd);
+               @ans = (0) if !$package ;
+               
+               if ($package) {
+                       my $c = qq{ \@ans = $package(\$self, \$args) };
+                       dbg('eval', "cluster cmd = $c\n");
+                       eval  $c;
+                       if ($@) {
+                               @ans = (0, "Syserr: Eval err cached $package\n$@");
+                       }
+               }
        }
-  }
-       
-  if ($ans[0]) {
-    shift @ans;
-  } else {
-    shift @ans;
-       if (@ans > 0) {
-               unshift @ans, $self->msg('e2');
+
+       if ($ans[0]) {
+               shift @ans;
        } else {
-               @ans = $self->msg('e1');
+               shift @ans;
+               if (@ans > 0) {
+                       unshift @ans, $self->msg('e2');
+               } else {
+                       @ans = $self->msg('e1');
+               }
        }
-  }
-  return (@ans);
+       return (@ans);
 }
 
 #
index 3227195747d5dcfd347cbd800bc40c957ebe71f3..5b35ee2dc83fb98c236d9f0055766f93eaf973de 100755 (executable)
@@ -52,7 +52,7 @@ sub cease
        if ($conn && $sendz) {
                $conn->send_now("Z$call|bye...\n");
        }
-       $stdout->flush;
+       $stdout->flush if $stdout;
        kill(15, $pid) if $pid;
        sleep(1);
        exit(0);        
@@ -395,3 +395,4 @@ for (;;) {
        }
 }
 
+exit(0);