- Timestamp:
- Mar 9, 2013, 10:20:21 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Base.pm
r1663 r1711 135 135 The first parameter is the shell command to call. This command should NOT use redirections. 136 136 The second parameter is the message to print on screen. If none is given, then the command is printed. 137 The third parameter prints the result of the command after correct execution if value is "verbose". If value is "noredir", it avoids redirecting outputs (e.g. for vi). If value is "quiet", doesn't print anything at all. If value is "mayfail", failure of the command is ok even if $Global::pb_stop_on_error is set, because the caller will be handling the error. A "verbose" can be added to mayfail to have it explain why it failed 137 The third parameter prints the result of the command after correct execution if value is "verbose". If value is "noredir", it avoids redirecting outputs (e.g. for vi). If value is "quiet", doesn't print anything at all. If value is "mayfail", failure of the command is ok even if $Global::pb_stop_on_error is set, because the caller will be handling the error. A "verbose" can be added to mayfail to have it explain why it failed. If value is verbose_PREF, then every output command will be prefixed with PREF. 138 138 This function returns as a result the return value of the system command. 139 139 … … 163 163 pb_log(0,"NOT OK but non blocking\n") if ($res != 0); 164 164 pb_log(0,"OK\n") if ($res == 0); 165 pb_display_file("$ENV{'PBTMP'}/system.$$.log" ) if ((-f "$ENV{'PBTMP'}/system.$$.log") and (defined $verbose) and ($verbose =~ /verbose/));165 pb_display_file("$ENV{'PBTMP'}/system.$$.log",undef,$verbose) if ((-f "$ENV{'PBTMP'}/system.$$.log") and (defined $verbose) and ($verbose =~ /verbose/)); 166 166 return($res) 167 167 } … … 175 175 if (defined $error) { 176 176 pb_log(0, $error) if (((! defined $verbose) || ($verbose ne "quiet")) || ($Global::pb_stop_on_error)); 177 pb_display_file("$ENV{'PBTMP'}/system.$$.log" ) if ((-f "$ENV{'PBTMP'}/system.$$.log") and ((! defined $verbose) || ($verbose ne "quiet") || $Global::pb_stop_on_error));177 pb_display_file("$ENV{'PBTMP'}/system.$$.log",undef,$verbose) if ((-f "$ENV{'PBTMP'}/system.$$.log") and ((! defined $verbose) || ($verbose ne "quiet") || $Global::pb_stop_on_error)); 178 178 if ($Global::pb_stop_on_error) { 179 179 confess("ERROR running command ($cmd) with cwd=$cwd, pid=$$"); … … 183 183 } else { 184 184 pb_log(0,"OK\n") if ((! defined $verbose) || ($verbose ne "quiet")); 185 pb_display_file("$ENV{'PBTMP'}/system.$$.log" ) if ((-f "$ENV{'PBTMP'}/system.$$.log") and (defined $verbose) and ($verbose ne "quiet"));185 pb_display_file("$ENV{'PBTMP'}/system.$$.log",undef,$verbose) if ((-f "$ENV{'PBTMP'}/system.$$.log") and (defined $verbose) and ($verbose ne "quiet")); 186 186 } 187 187 … … 290 290 =item B<pb_display_file> 291 291 292 This function print the content of the file passed in parameter.292 This function prints the content of the file passed in parameter. 293 293 If a second parameter is given, this is the descriptor of the logfile to write to in addtion to STDOUT. 294 If a third parameter is given, this is the prefix providing it's writen as verbose_PREF. In which case the PREF string will be added before the line output. 294 295 295 296 This is a cat equivalent function. … … 301 302 my $file=shift; 302 303 my $desc=shift || undef; 304 my $prefix=shift; 303 305 304 306 return if (not -f $file); 305 307 my $cnt = pb_get_content($file); 306 print "$cnt\n"; 307 print $desc "$cnt\n" if (defined $desc); 308 # If we have a prefix, then add it at each line 309 if ((defined $prefix) and ($prefix =~ "_")) { 310 $prefix =~ s/verbose_//; 311 $cnt =~ s/\n/\n$prefix/g; 312 } else { 313 $prefix = ""; 314 } 315 print "$prefix$cnt\n"; 316 print $desc "$prefix$cnt\n" if (defined $desc); 308 317 } 309 318
Note:
See TracChangeset
for help on using the changeset viewer.