Changeset 22518 for main


Ignore:
Timestamp:
2010-07-28T15:06:55+12:00 (14 years ago)
Author:
kjdon
Message:

copied the pager code out of printusage and added it to print_single_{plugin,classifier} so that pluginfo and classinfo go to less

Location:
main/trunk/greenstone2/bin/script
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/classinfo.pl

    r21292 r22518  
    214214    }
    215215    else {
     216
     217    # this causes us to automatically send output to a pager, if one is
     218    # set, AND our output is going to a terminal
     219    # active state perl on windows doesn't do open(handle, "-|");
     220    if ($ENV{'GSDLOS'} !~ /windows/ && -t STDOUT) {
     221        my $pager = $ENV{"PAGER"};
     222        if (! $pager) {$pager="(less || more)"}
     223        my $pid = open(STDIN, "-|"); # this does a fork... see man perlipc(1)
     224        if (!defined $pid) {
     225        gsprintf(STDERR, "pluginfo.pl - can't fork: $!");
     226        } else {
     227        if ($pid != 0) { # parent (ie forking) process. child gets 0
     228            exec ($pager);
     229        }
     230        }
     231        open(STDERR,">&STDOUT"); # so it's easier to pipe output
     232    }
     233
    216234    &gsprintf(STDERR, "\n{classinfo.passing_options}\n\n");
    217235    &gsprintf(STDERR, "{classinfo.option_types}:\n\n");
  • main/trunk/greenstone2/bin/script/pluginfo.pl

    r22331 r22518  
    249249    }
    250250    else {
     251
     252    # this causes us to automatically send output to a pager, if one is
     253    # set, AND our output is going to a terminal
     254    # active state perl on windows doesn't do open(handle, "-|");
     255    if ($ENV{'GSDLOS'} !~ /windows/ && -t STDOUT) {
     256        my $pager = $ENV{"PAGER"};
     257        if (! $pager) {$pager="(less || more)"}
     258        my $pid = open(STDIN, "-|"); # this does a fork... see man perlipc(1)
     259        if (!defined $pid) {
     260        gsprintf(STDERR, "pluginfo.pl - can't fork: $!");
     261        } else {
     262        if ($pid != 0) { # parent (ie forking) process. child gets 0
     263            exec ($pager);
     264        }
     265        }
     266        open(STDERR,">&STDOUT"); # so it's easier to pipe output
     267    }
     268
    251269    gsprintf(STDERR, "\n{pluginfo.passing_options}\n\n");
    252270    gsprintf(STDERR, "{pluginfo.option_types}:\n\n");
Note: See TracChangeset for help on using the changeset viewer.