Changeset 5638


Ignore:
Timestamp:
2003-10-15T14:53:37+13:00 (21 years ago)
Author:
jrm21
Message:

automatically send output to a pager if not on windows, so you can read the
scroll.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/pluginfo.pl

    r5606 r5638  
    100100
    101101
    102 #  sub print_usage {
    103 #      print STDERR "\n";
    104 #      print STDERR "pluginfo.pl: Prints information about a plugin.\n\n";
    105 #      print STDERR " usage: $0 [options] plugin\n\n";
    106 #      print STDERR " options:\n";
    107 #      print STDERR "  -collect collection-name  Giving a collection name will make pluginfo.pl\n";
    108 #      print STDERR "                            look in collect/collection-name/perllib/plugins\n";
    109 #      print STDERR "                            first. If the plugin is not found there it will\n";
    110 #      print STDERR "                            look in the general perllib/plugins directory.\n\n";
    111 #      print STDERR "  -xml                      Produces the information in an xml form, without\n";
    112 #      print STDERR "                            'pretty' comments but with much more detail.\n\n";
    113 #      print STDERR "  -language language-code   Language to display plugin options in (eg. 'en_US'\n";
    114 #      print STDERR "                            specifies American English). Requires translations\n";
    115 #      print STDERR "                            of the option descriptions to exist in the\n";
    116 #      print STDERR "                            perllib/strings_language-code.rb file.\n";
    117 #  }
    118102
    119103sub main {
     
    158142
    159143    $plugobj->print_txt_usage($language);
    160 
    161 #   print STDERR " The default process_exp for $plugin is: ";
    162 #   print STDERR "\"" . $plugobj->get_default_process_exp() . "\"\n\n";
    163 
    164 #   print STDERR " The default block_exp for $plugin is: ";
    165 #   print STDERR "\"" . $plugobj->get_default_block_exp() . "\"\n\n";
    166144    }
    167145}
    168146
    169147
     148# this causes us to automatically send output to a pager, if one is
     149# set, AND our output is going to a terminal
     150# active state perl on windows doesn't do open(handle, "-|");
     151if ($ENV{'GSDLOS'} !~ /windows/ && -t STDOUT) {
     152    my $pager = $ENV{"PAGER"};
     153    if (! $pager) {$pager="(less || more)"}
     154    $pid = open(STDIN, "-|"); # this does a fork... see man perlipc(1)
     155    if (!defined $pid) {
     156    print STDERR "pluginfo.pl - can't fork: $!";
     157    } else {
     158    if ($pid != 0) { # parent (ie forking) process. child gets 0
     159        exec ($pager);
     160    }
     161    }
     162    open(STDERR,">&STDOUT"); # so it's easier to pipe output
     163}
     164
     165
    170166&main ();
Note: See TracChangeset for help on using the changeset viewer.