Skip to content

Commit

Permalink
export_report: do collectcfiles work in perl itself
Browse files Browse the repository at this point in the history
Avoid spawning a shell pipeline doing cat, grep, sed, and do it all
inside perl.  The <*.c> globbing construct works at least as far back
as 5.8.9

Note that this is not just an optimization; the sed command
in the pipeline was unterminated, due to lack of escape on the
end-of-line (\$) in the regex, resulting in this:

    $ perl ../linux-2.6/scripts/export_report.pl  > /dev/null
    sed: -e expression #1, char 5: unterminated `s' command
    sh: .mod.c/: not found

Comments on an earlier patch sought an all-perl implementation.

Signed-off-by: Jim Cromie <[email protected]>
cc: Michal Marek <[email protected]>,
cc: [email protected]
cc: Arnaud Lacombe [email protected]
cc: Stephen Hemminger [email protected]
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
jimc authored and michal42 committed May 24, 2011
1 parent 2ee2d29 commit de7b0b4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/export_report.pl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ sub usage {
}

sub collectcfiles {
my @file
= `cat .tmp_versions/*.mod | grep '.*\.ko\$' | sed s/\.ko$/.mod.c/`;
my @file;
while (<.tmp_versions/*.mod>) {
open my $fh, '<', $_ or die "cannot open $_: $!\n";
push (@file,
grep s/\.ko/.mod.c/, # change the suffix
grep m/.+\.ko/, # find the .ko path
<$fh>); # lines in opened file
}
chomp @file;
return @file;
}
Expand Down

0 comments on commit de7b0b4

Please sign in to comment.