This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Execute files of debugger commands
authorPeter Scott <Peter@PSDT.com>
Thu, 13 Sep 2001 15:26:31 +0000 (08:26 -0700)
committerJarkko Hietaniemi <jhi@iki.fi>
Fri, 14 Sep 2001 02:31:05 +0000 (02:31 +0000)
Message-Id: <4.3.2.7.2.20010913115845.00b22100@mail.webquarry.com>

p4raw-id: //depot/perl@12014

lib/perl5db.pl
pod/perldebug.pod

index ab9c48d..6f1b20a 100644 (file)
@@ -1433,6 +1433,14 @@ EOP
                            } 
                        }
                        next CMD; };
+                   $cmd =~ /^\@\s*(.*\S)/ && do {
+                     if (open my $fh, $1) {
+                       push @cmdfhs, $fh;
+                     }
+                     else {
+                       &warn("Can't execute `$1': $!\n");
+                     }
+                     next CMD; };
                    $cmd =~ /^\|\|?\s*[^|]/ && do {
                        if ($pager =~ /^\|/) {
                            open(SAVEOUT,">&STDOUT") || &warn("Can't save STDOUT");
@@ -2105,6 +2113,11 @@ sub readline {
   }
   local $frame = 0;
   local $doret = -2;
+  while (@cmdfhs) {
+    my $line = CORE::readline($cmdfhs[-1]);
+    defined $line ? (print $OUT ">> $line" and return $line)
+                  : close pop @cmdfhs;
+  }
   if (ref $OUT and UNIVERSAL::isa($OUT, 'IO::Socket::INET')) {
     $OUT->write(join('', @_));
     my $stuff;
@@ -2487,6 +2500,7 @@ B<$psh$psh> I<cmd>        Run cmd in a subprocess (reads from DB::IN, writes to DB::O
   . ( $rc eq $sh ? "" : "
 B<$psh> [I<cmd>]       Run I<cmd> in subshell (forces \"\$SHELL -c 'cmd'\")." ) . "
                See 'B<O> I<shellBang>' too.
+B<@>I<file>            Execute I<file> containing debugger commands (may nest).
 B<H> I<-number>        Display last number commands (default all).
 B<p> I<expr>           Same as \"I<print {DB::OUT} expr>\" in current package.
 B<|>I<dbcmd>           Run debugger command, piping DB::OUT to current pager.
index 326bdab..6232925 100644 (file)
@@ -387,6 +387,11 @@ their C<$ENV{SHELL}> variable) will be used, which can interfere
 with proper interpretation of exit status or signal and coredump
 information.
 
+=item @ file
+
+Read and execute debugger commands from I<file>.  I<file> may itself contain
+C<@> commands.
+
 =item H -number
 
 Display last n commands.  Only commands longer than one character are