1 #!/usr/local/bin/perl -w
2 # Id: infosrch,v 1.2 2004/04/11 17:56:47 karl Exp
3 # infosrch does a regex search on an info manual.
4 # By Harry Putnam <reader@newsguy.com>.
6 ($myscript = $0) =~ s
:^.*/::;
9 if($ARGV[0] eq "help"){
25 $shell_proc = "info --output - --subnodes 2>/dev/null $target";
27 open(SHELL_PROC
," $shell_proc|");
35 if(/$regex/ && !$six){
36 print "$target\n $lines[($cnt-1)]\n<$cnt> $lines[$cnt]\n $lines[($cnt+1)]\n";
38 }elsif(/$regex/ && $six){
41 print " $lines[($cnt-6)]\n";
44 print " $lines[($cnt-5)]\n";
47 print " $lines[($cnt-4)]\n";
50 print " $lines[($cnt-3)]\n";
53 print " $lines[($cnt-2)]\n";
56 print " $lines[($cnt-1)]\n";
59 print "$cnt $lines[$cnt]\n";
62 print " $lines[($cnt+1)]\n";
65 print " $lines[($cnt+2)]\n";
68 print " $lines[($cnt+3)]\n";
71 print " $lines[($cnt+4)]\n";
74 print " $lines[($cnt+5)]\n";
77 print " $lines[($cnt+6)]\n";
87 Purpose: Extract full text from info node and search it by regex
88 Usage: $myscript [-e] TARGET REGEX
90 Where TARGET is an info node such as `emacs', `bash' etc, and
91 REGEX is what you want to find in it.
93 The -e flag is not required but if used then 6 lines preceding and six
94 lines following any hits will be printed. The default (with no -e flag)
95 is to print one line before and after.
97 The output has the line number prepended to the line containing the
101 info --output - --subnodes 2>/dev/null TARGET