Changeset 473 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder/Base.pm


Ignore:
Timestamp:
Jun 4, 2008, 3:04:36 AM (16 years ago)
Author:
Bruno Cornec
Message:

Working announce action for pb

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/Base.pm

    r471 r473  
    126126The first parameter is the shell command to call.
    127127The second parameter is the message to print on screen. If none is given, then the command is printed.
     128The third parameter print the result of the command after correct execution if value is verbose. If value is noredir, it avoids redirecting outputs (e.g. for vi).
    128129This function returns the result the return value of the system command.
    129130
     
    137138my $cmt=shift || $cmd;
    138139my $verbose=shift || undef;
     140my $redir = "";
    139141
    140142pb_log(0,"$cmt... ");
    141143pb_log(1,"Executing $cmd\n");
    142 system("$cmd 2>&1 > $ENV{'PBTMP'}/system.log");
     144$redir = "2>&1 > $ENV{'PBTMP'}/system.log" if ((! defined $verbose) || ($verbose ne "noredir"));
     145system("$cmd $redir");
    143146my $res = $?;
    144147if ($res == -1) {
    145148    pb_log(0,"failed to execute ($cmd): $!\n");
    146     pb_display_file("$ENV{'PBTMP'}/system.log");
     149    pb_display_file("$ENV{'PBTMP'}/system.log") if (-f "$ENV{'PBTMP'}/system.log");
    147150} elsif ($res & 127) {
    148151    pb_log(0, "child ($cmd) died with signal ".($? & 127).", ".($? & 128) ? 'with' : 'without'." coredump\n");
    149     pb_display_file("$ENV{'PBTMP'}/system.log");
     152    pb_display_file("$ENV{'PBTMP'}/system.log") if (-f "$ENV{'PBTMP'}/system.log");
    150153} elsif ($res == 0) {
    151154    pb_log(0,"OK\n");
    152     pb_display_file("$ENV{'PBTMP'}/system.log") if (defined $verbose);
     155    pb_display_file("$ENV{'PBTMP'}/system.log") if ((defined $verbose) && (-f "$ENV{'PBTMP'}/system.log"));
    153156} else {
    154157    pb_log(0, "child ($cmd) exited with value ".($? >> 8)."\n");
    155     pb_display_file("$ENV{'PBTMP'}/system.log");
     158    pb_display_file("$ENV{'PBTMP'}/system.log") if (-f "$ENV{'PBTMP'}/system.log");
    156159}
    157160return($res);
Note: See TracChangeset for help on using the changeset viewer.