Messages in this thread Patch in this message | | | Date | Thu, 10 Jan 2008 20:11:20 -0800 | Date | Thu, 10 Jan 2008 20:10:30 -0800 | From | Daniel Walker <> | Subject | [PATCH] checkpatch.pl: allow piping |
| |
A little feature addition to allow checkpatch.pl to check patches piped into it, in addition to specific file arguments.
Signed-off-by: Daniel Walker <dwalker@mvista.com> --- scripts/checkpatch.pl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
Index: linux-2.6.23/scripts/checkpatch.pl =================================================================== --- linux-2.6.23.orig/scripts/checkpatch.pl +++ linux-2.6.23/scripts/checkpatch.pl @@ -24,6 +24,7 @@ my $file = 0; my $check = 0; my $summary = 1; my $mailback = 0; +my $piped = (-t STDIN) ? 0 : 1; my $root; GetOptions( 'q|quiet+' => \$quiet, @@ -43,7 +44,7 @@ GetOptions( my $exit = 0; -if ($#ARGV < 0) { +if ($#ARGV < 0 && !$piped) { print "usage: $P [options] patchfile\n"; print "version: $V\n"; print "options: -q => quiet\n"; @@ -181,6 +182,18 @@ if ($tree && -f "$root/$removal") { } my @rawlines = (); + +if ($piped) { + while (<STDIN>) { + chomp; + push(@rawlines, $_); + } + if (!process("", @rawlines)) { + $exit = 1; + } + @rawlines = (); +} + for my $filename (@ARGV) { if ($file) { open(FILE, "diff -u /dev/null $filename|") || -- --
| |