Commit de7b0b4110795be914e6cafdfec4276b2618cc78

Authored by Jim Cromie
Committed by Michal Marek
1 parent 2ee2d29289

export_report: do collectcfiles work in perl itself

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 <jim.cromie@gmail.com>
cc: Michal Marek <mmarek@suse.cz>,
cc: linux-kbuild@vger.kernel.org
cc: Arnaud Lacombe lacombar@gmail.com
cc: Stephen Hemminger shemminger@vyatta.com
Signed-off-by: Michal Marek <mmarek@suse.cz>

Showing 1 changed file with 8 additions and 2 deletions Side-by-side Diff

scripts/export_report.pl
... ... @@ -49,8 +49,14 @@
49 49 }
50 50  
51 51 sub collectcfiles {
52   - my @file
53   - = `cat .tmp_versions/*.mod | grep '.*\.ko\$' | sed s/\.ko$/.mod.c/`;
  52 + my @file;
  53 + while (<.tmp_versions/*.mod>) {
  54 + open my $fh, '<', $_ or die "cannot open $_: $!\n";
  55 + push (@file,
  56 + grep s/\.ko/.mod.c/, # change the suffix
  57 + grep m/.+\.ko/, # find the .ko path
  58 + <$fh>); # lines in opened file
  59 + }
54 60 chomp @file;
55 61 return @file;
56 62 }