Changeset 10984 for trunk/gsdl


Ignore:
Timestamp:
2005-12-09T11:35:10+13:00 (18 years ago)
Author:
jrm21
Message:

move the terminal detection/pager redirection stuff from pluginfo.pl to
the usage module so that all command-line scripts using print_usage_txt()
benefit.

Location:
trunk/gsdl
Files:
2 edited

Legend:

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

    r10825 r10984  
    194194}
    195195
    196 
    197 # this causes us to automatically send output to a pager, if one is
    198 # set, AND our output is going to a terminal
    199 # active state perl on windows doesn't do open(handle, "-|");
    200 if ($ENV{'GSDLOS'} !~ /windows/ && -t STDOUT) {
    201     my $pager = $ENV{"PAGER"};
    202     if (! $pager) {$pager="(less || more)"}
    203     my $pid = open(STDIN, "-|"); # this does a fork... see man perlipc(1)
    204     if (!defined $pid) {
    205     gsprintf(STDERR, "pluginfo.pl - can't fork: $!");
    206     } else {
    207     if ($pid != 0) { # parent (ie forking) process. child gets 0
    208         exec ($pager);
    209     }
    210     }
    211     open(STDERR,">&STDOUT"); # so it's easier to pipe output
    212 }
    213 
    214 
    215196&main ();
  • trunk/gsdl/perllib/printusage.pm

    r10324 r10984  
    177177    my $programdesc = shift(@_);
    178178
     179    # this causes us to automatically send output to a pager, if one is
     180    # set, AND our output is going to a terminal
     181    # active state perl on windows doesn't do open(handle, "-|");
     182    if ($ENV{'GSDLOS'} !~ /windows/ && -t STDOUT) {
     183        my $pager = $ENV{"PAGER"};
     184    if (! $pager) {$pager="(less || more)"}
     185    my $pid = open(STDIN, "-|"); # this does a fork... see man perlipc(1)
     186    if (!defined $pid) {
     187        gsprintf(STDERR, "pluginfo.pl - can't fork: $!");
     188    } else {
     189        if ($pid != 0) { # parent (ie forking) process. child gets 0
     190        exec ($pager);
     191        }
     192    }
     193    open(STDERR,">&STDOUT"); # so it's easier to pipe output
     194    }
     195
     196
     197
    179198    my $programname = $options->{'name'};
    180199    my $programargs = $options->{'args'};
Note: See TracChangeset for help on using the changeset viewer.