Changeset 6988


Ignore:
Timestamp:
2004-03-09T16:16:28+13:00 (20 years ago)
Author:
jrm21
Message:

every perl script should start with "use strict"....

use language setting in LC_ALL or LANG environment variable if not set as
an option.

File:
1 edited

Legend:

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

    r6945 r6988  
    2828# This program will print info about a plugin
    2929
    30 # @revision 09/05/02 Added XML usage information flag - John Thompson
     30use strict;
     31no strict 'subs'; # allow barewords (eg STDERR) as function arguments
    3132
    3233BEGIN {
     
    7374    my $xml = 0;
    7475
     76    my $language;
     77
    7578    if (!parsargv::parse(\@ARGV,
    7679             q^collect/.*/^, \$collect,
     
    7881             q^language/.*/^, \$language))
    7982    {
    80     &PrintUsage::print_txt_usage($options, "{pluginfo.params}", 1);
     83    PrintUsage::print_txt_usage($options, "{pluginfo.params}", 1);
    8184    die "\n";
    8285    }
    8386
    84     # If $language has been specified, load the appropriate resource bundle
     87    # if language wasn't specified, see if it is set in the environment
     88    # (LC_ALL or LANG)
     89    if (!$language && ($_=$ENV{'LC_ALL'} or $_=$ENV{'LANG'})) {
     90    m/^([^\.]+)\.?(.*)/;
     91    $language=$1;
     92# gsprintf doesn't do anything about encoding, hard-coded to iso-8859-1!!
     93    # my $encoding=$2; # might be undef...
     94# gsprintf::load_language* thinks "fr" is completely different to "fr_FR"...
     95    $language =~ s/_.*$//;
     96    }
     97
     98    # If $language has been set, load the appropriate resource bundle
    8599    # (Otherwise, the default resource bundle will be loaded automatically)
    86100    if ($language) {
    87     &gsprintf::load_language_specific_resource_bundle($language);
     101    gsprintf::load_language_specific_resource_bundle($language);
    88102    }
    89103
    90104    my $plugin = shift (@ARGV);
    91105    if (!defined $plugin || $plugin eq "") {
    92     &gsprintf(STDERR, "{pluginfo.no_plugin_name}\n\n");
    93     &PrintUsage::print_txt_usage($options, "{pluginfo.params}", 1);
     106    gsprintf(STDERR, "{pluginfo.no_plugin_name}\n\n");
     107    PrintUsage::print_txt_usage($options, "{pluginfo.params}", 1);
    94108    die "\n";
    95109    }
     
    108122    }
    109123    else {
    110     &gsprintf(STDERR, "\n{pluginfo.passing_options}\n\n");
    111     &gsprintf(STDERR, "{pluginfo.option_types}:\n\n");
    112     &gsprintf(STDERR, "{pluginfo.specific_options}\n\n");
    113     &gsprintf(STDERR, "{pluginfo.general_options}\n\n");
    114     &gsprintf(STDERR, "$plugin {pluginfo.info}:\n\n");
     124    gsprintf(STDERR, "\n{pluginfo.passing_options}\n\n");
     125    gsprintf(STDERR, "{pluginfo.option_types}:\n\n");
     126    gsprintf(STDERR, "{pluginfo.specific_options}\n\n");
     127    gsprintf(STDERR, "{pluginfo.general_options}\n\n");
     128    gsprintf(STDERR, "$plugin {pluginfo.info}:\n\n");
    115129
    116130    $plugobj->print_txt_usage();
     
    125139    my $pager = $ENV{"PAGER"};
    126140    if (! $pager) {$pager="(less || more)"}
    127     $pid = open(STDIN, "-|"); # this does a fork... see man perlipc(1)
     141    my $pid = open(STDIN, "-|"); # this does a fork... see man perlipc(1)
    128142    if (!defined $pid) {
    129     &gsprintf(STDERR, "pluginfo.pl - can't fork: $!");
     143    gsprintf(STDERR, "pluginfo.pl - can't fork: $!");
    130144    } else {
    131145    if ($pid != 0) { # parent (ie forking) process. child gets 0
Note: See TracChangeset for help on using the changeset viewer.