@@ -744,14 +744,11 @@ sub load_rexfile {
744
744
}
745
745
};
746
746
747
- my ( $stdout , $stderr , $default_stderr );
748
- open $default_stderr , " >&" , STDERR ;
749
-
750
- # we close STDERR here because we don't want to see the
751
- # normal perl error message on the screen. Instead we print
752
- # the error message in the catch-if below.
753
- local *STDERR ;
754
- open ( STDERR , " >>" , \$stderr );
747
+ # we don't want to see the
748
+ # normal perl warning message on the screen. Instead we print
749
+ # the warning message in the catch-if below
750
+ my @warnings ;
751
+ local $SIG {__WARN__ } = sub { push @warnings , $_ [0] };
755
752
756
753
# we can't use $rexfile here, because if the variable contains dots
757
754
# the perl interpreter try to load the file directly without using @INC
@@ -761,13 +758,13 @@ sub load_rexfile {
761
758
# update %INC so that we can later use it to find the rexfile
762
759
$INC {" __Rexfile__.pm" } = $rexfile ;
763
760
764
- # reopen STDERR
765
- open STDERR , " >&" , $default_stderr ;
766
-
767
- if ($stderr ) {
768
- my @lines = split ( $/ , $stderr );
761
+ if (@warnings ) {
769
762
Rex::Logger::info( " You have some code warnings:" , ' warn' );
770
- Rex::Logger::info( " \t $_ " , ' warn' ) for @lines ;
763
+ for (@warnings ) {
764
+ # remove /loader/.../ prefix before filename
765
+ s | /loader/[^/]+/|| ;
766
+ Rex::Logger::info( " \t $_ " , ' warn' );
767
+ }
771
768
}
772
769
773
770
1;
0 commit comments