checkpatch.pl: allow piping
PATCH 1/1 checkpatch.pl: allow piping
A little feature addition to allow checkpatch.pl to check patches piped into it, in addition to specific file arguments.
--- scripts/checkpatch.pl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +14 -1
@@ -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|") ||
Signature · 1 line
--
Quoted 2 lines · Daniel Walker
A little feature addition to allow checkpatch.pl to check patches piped into it, in addition to specific file arguments.
You can still add - as an argument to check stdin. In which way is this better?
regards,
Signature · 3 lines
Jiri Slaby Faculty of Informatics, Masaryk University Suse Labs
Quoted 5 lines · Jiri Slaby
Quoted 2 lines · Daniel Walker
A little feature addition to allow checkpatch.pl to check patches piped into it, in addition to specific file arguments.
You can still add - as an argument to check stdin. In which way is this better?
There's was no reason to limit the arguments ..
I was using it to do something like the following ,
git show 9914cad54c79d0b89b1f066c0894f00e1344131c | ./scripts/checkpatch.pl
Which I think is useful .
Dainel
Quoted 11 lines · Daniel Walker
Quoted 4 lines · Jiri Slaby
Quoted 2 lines · Daniel Walker
A little feature addition to allow checkpatch.pl to check patches piped into it, in addition to specific file arguments.
You can still add - as an argument to check stdin. In which way is this better?
There's was no reason to limit the arguments ..
I was using it to do something like the following ,
git show
9914cad54c79d0b89b1f066c0894f00e1344131c|./scripts/checkpatch.pl
Ok, and if you add a - there, it should have the same effect, but for free, doesn't it:
git show 9914cad54c79d0b89b1f066c0894f00e1344131c | ./scripts/checkpatch.pl -
regards,
Signature · 3 lines
Jiri Slaby Faculty of Informatics, Masaryk University Suse Labs
Quoted 9 lines · Jiri Slaby
Quoted 8 lines · Daniel Walker
Quoted 4 lines · Jiri Slaby
Quoted 2 lines · Daniel Walker
A little feature addition to allow checkpatch.pl to check patches piped into it, in addition to specific file arguments.
You can still add - as an argument to check stdin. In which way is this better?
There's was no reason to limit the arguments ..
Quoted 7 lines
Quoted 3 lines
I was using it to do something like the following ,
git show
9914cad54c79d0b89b1f066c0894f00e1344131c|./scripts/checkpatch.plOk, and if you add a - there, it should have the same effect, but for free, doesn't it:
git show9914cad54c79d0b89b1f066c0894f00e1344131c|./scripts/checkpatch.pl-
JftSoC:
git show 9914cad54c79d0b89b1f066c0894f00e1344131c | ./scripts/checkpatch.pl /dev/stdin (and there a a few others) should also do the trick.
Bernd
Signature · 3 lines
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and ServicesQuoted 19 lines · Bernd Petrovitsch
Quoted 4 lines · Jiri Slaby
Quoted 3 lines · Daniel Walker
Quoted 2 lines · Jiri Slaby
Quoted 1 line · Daniel Walker
A little feature addition to allow checkpatch.pl to check
patches piped
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
into it, in addition to specific file arguments.
You can still add - as an argument to check stdin. In which way
is this better?
Quoted 6 lines
Quoted 6 lines
There's was no reason to limit the arguments ..
I was using it to do something like the following ,
git show
9914cad54c79d0b89b1f066c0894f00e1344131c|
./scripts/checkpatch.plQuoted 2 lines
Ok, and if you add a - there, it should have the same effect, but
for free,
Quoted 8 lines
Quoted 2 lines
doesn't it:
git show9914cad54c79d0b89b1f066c0894f00e1344131c|
./scripts/checkpatch.pl-JftSoC:
git show9914cad54c79d0b89b1f066c0894f00e1344131c|./scripts/checkpatch.pl/dev/stdin
(and there a a few others) should also do the trick.
Not a particularly attractive command line .. Might still be a good idea to add this since these two forms alluded me, and are likely to allude people new to unix all together (who is more likely to be using this particular tool)..
Daniel
Quoted 10 lines · Daniel Walker
Quoted 8 lines · Bernd Petrovitsch
Quoted 1 line · Jiri Slaby
git show
9914cad54c79d0b89b1f066c0894f00e1344131c|
./scripts/checkpatch.pl-JftSoC:
git show9914cad54c79d0b89b1f066c0894f00e1344131c|./scripts/checkpatch.pl/dev/stdin
(and there a a few others) should also do the trick.
Quoted 4 lines
Not a particularly attractive command line .. Might still be a good idea to add this since these two forms alluded me, and are likely to allude people new to unix all together (who is more likely to be using this particular tool)..
If somebody is hacking kernel, I think he should know the - trick used in many programs, but do not consider this as a nack.
thanks,
Signature · 3 lines
Jiri Slaby Faculty of Informatics, Masaryk University Suse Labs
Quoted 11 lines · Jiri Slaby
Quoted 10 lines · Daniel Walker
Quoted 8 lines · Bernd Petrovitsch
Quoted 1 line · Jiri Slaby
git show
9914cad54c79d0b89b1f066c0894f00e1344131c|
./scripts/checkpatch.pl-JftSoC:
git show9914cad54c79d0b89b1f066c0894f00e1344131c|./scripts/checkpatch.pl/dev/stdin
(and there a a few others) should also do the trick.
Quoted 7 lines
Quoted 4 lines
Not a particularly attractive command line .. Might still be a good idea to add this since these two forms alluded me, and are likely to allude people new to unix all together (who is more likely to be using this particular tool)..
If somebody is hacking kernel, I think he should know the - trick used in many programs, but do not consider this as a nack.
I'm hacking the kernel, and I didn't know the - trick .. So you have your testing case all in one with the patch submitter ..
Daniel
Quoted 5 lines · Daniel Walker
Quoted 1 line · Jiri Slaby
If somebody is hacking kernel, I think he should know the - trick used in many programs, but do not consider this as a nack.
I'm hacking the kernel, and I didn't know the - trick .. So you have your testing case all in one with the patch submitter ..
OK, maybe we should base it in doc for patch submitting then?
regards,
Signature · 3 lines
Jiri Slaby Faculty of Informatics, Masaryk University Suse Labs
Quoted 9 lines · Jiri Slaby
Quoted 6 lines · Daniel Walker
Quoted 2 lines · Jiri Slaby
If somebody is hacking kernel, I think he should know the - trick used in many programs, but do not consider this as a nack.
I'm hacking the kernel, and I didn't know the - trick .. So you have your testing case all in one with the patch submitter ..
OK, maybe we should base it in doc for patch submitting then?
It's in the bash docs I'm sure, it's just a matter of who ends up reading that part of the docs.. I still think my patch is a good one , we could change the name to "Allow piping with out tricks" I suppose ..
Daniel
Quoted 6 lines · Daniel Walker
Quoted 5 lines · Jiri Slaby
Quoted 4 lines · Daniel Walker
Quoted 2 lines · Jiri Slaby
If somebody is hacking kernel, I think he should know the - trick used in many programs, but do not consider this as a nack.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
I'm hacking the kernel, and I didn't know the - trick .. So you have your testing case all in one with the patch submitter ..
OK, maybe we should base it in doc for patch submitting then?
It's in the bash docs I'm sure, it's just a matter of who ends up
Yes, too. And "awk" also supports that.
But "/dev/stdin" is also since ages a symlink to "/proc/self/fd/0" (which is another equivalent "file").
Quoted 2 lines
reading that part of the docs.. I still think my patch is a good one , we could change the name to "Allow piping with out tricks" I suppose ..
Bernd
Signature · 3 lines
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and ServicesQuoted 10 lines · Daniel Walker
Quoted 6 lines · Jiri Slaby
Quoted 3 lines
Quoted 3 lines · Jiri Slaby
Quoted 1 line
git show
9914cad54c79d0b89b1f066c0894f00e1344131c|
./scripts/checkpatch.pl-If somebody is hacking kernel, I think he should know the - trick used in many programs, but do not consider this as a nack.
I'm hacking the kernel, and I didn't know the - trick .. So you have your testing case all in one with the patch submitter ..
How about
if ($#ARGV < 0) {
print "usage: $P [options] patchfile\n";
print "version: $V\n";
print "options: -q => quiet\n"; print " --no-tree => run without a kernel tree\n"; print " --terse => one line per report\n"; print " --emacs => emacs compile window format\n"; print " --file => check a source file\n"; print " --strict => enable more subjective tests\n"; print " --root => path to the kernel tree root\n";
+ print "When patchfile is -, read standard input.\n";
exit(1);
}
Signature · 3 lines
Stefan Richter -=====-==--- ---= -=-== http://arcgraph.de/sr/
Quoted 16 lines · Stefan Richter
Quoted 8 lines · Daniel Walker
Quoted 5 lines · Jiri Slaby
Quoted 3 lines
Quoted 3 lines · Jiri Slaby
Quoted 1 line
git show
9914cad54c79d0b89b1f066c0894f00e1344131c|
./scripts/checkpatch.pl-If somebody is hacking kernel, I think he should know the - trick used in many programs, but do not consider this as a nack.
I'm hacking the kernel, and I didn't know the - trick .. So you have your testing case all in one with the patch submitter ..
How about
if ($#ARGV < 0) {
(quoted diff) +0
-0print "usage: $P [options] patchfile\n"; print "version: $V\n";
Review
Quoted 10 lines
(quoted diff) +1
-0print "options: -q => quiet\n"; print " --no-tree => run without a kernel tree\n"; print " --terse => one line per report\n"; print " --emacs => emacs compile window format\n"; print " --file => check a source file\n"; print " --strict => enable more subjective tests\n"; print " --root => path to the kernel tree root\n"; + print "When patchfile is -, read standard input.\n"; exit(1); }
My ACK.
regards,
Signature · 3 lines
Jiri Slaby Faculty of Informatics, Masaryk University Suse Labs
PATCH 1/1 checkpatch.pl: show how to read from stdin
--- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
@@ -53,6 +53,7 @@ if ($#ARGV < 0) { print " --file => check a source file\n"; print " --strict => enable more subjective tests\n"; print " --root => path to the kernel tree root\n"; + print "When patchfile is -, read standard input.\n"; exit(1); }
Signature · 3 lines
Stefan Richter -=====-==--- ---= -=-== http://arcgraph.de/sr/
Re: [PATCH] checkpatch.pl: show how to read from stdin
Quoted 11 lines · Stefan Richter
Signed-off-by Stefan Richter <[email protected]>Acked-by Jiri Slaby <[email protected]>--- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+)Index:
linux/scripts/checkpatch.pl
===================================================================
scripts/checkpatch.pl if ($#ARGV < 0) { · line 59
Quoted 7 lines
scripts/checkpatch.pl +1
-0@@ -53,6 +53,7 @@ if ($#ARGV < 0) { print " --file => check a source file\n"; print " --strict => enable more subjective tests\n"; print " --root => path to the kernel tree root\n"; + print "When patchfile is -, read standard input.\n"; exit(1); }
Naww .. Why add documentation when you can just make it do the right thing ..
Daniel
Re: [PATCH] checkpatch.pl: show how to read from stdin
Quoted 6 lines · Daniel Walker
scripts/checkpatch.pl if ($#ARGV < 0) { · line 56
Quoted 2 lines · Stefan Richter
Signed-off-by Stefan Richter <[email protected]>scripts/checkpatch.pl +1
-0+ print "When patchfile is -, read standard input.\n";Naww .. Why add documentation when you can just make it do the right thing ..
Why add code for a feature which already exists?
Signature · 3 lines
Stefan Richter -=====-==--- ---= -=-== http://arcgraph.de/sr/
Re: [PATCH] checkpatch.pl: show how to read from stdin
Quoted 9 lines · Stefan Richter
Quoted 6 lines · Daniel Walker
scripts/checkpatch.pl if ($#ARGV < 0) { · line 56
Quoted 2 lines · Stefan Richter
Signed-off-by Stefan Richter <[email protected]>scripts/checkpatch.pl +1
-0+ print "When patchfile is -, read standard input.\n";Naww .. Why add documentation when you can just make it do the right thing ..
Why add code for a feature which already exists?
To make it simpler to use .. A good percentage (if not all) command line unix data processing utils accept piped data directly, without the need for the "-" .. That's the expect usage .. checkpatch.pl doesn't need to deviate from the norm, there is no size constraint, there is no line limit .. So we're not duplicating functionality, we're making the tool conform ..
Daniel
Re: [PATCH] checkpatch.pl: show how to read from stdin
In reply to Stefan RichterQuoted 2 lines · Stefan Richter
Signed-off-by Stefan Richter <[email protected]>Acked-by Jiri Slaby <[email protected]>
As an absolute minimum this seems reasonable to me. I guess we could make no arguments default to '-' also. There are up and downsides to doing that, as currently no arguments currently tell you the usage and with this patch would point clearly out the '-' option. Just assuming stding would lose easy access to usage, which may actually be more confusing for the beginner. Hmmm. Cirtainly will include this documentation change if nothing else.
Quoted 9 lines
--- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+)Index:
linux/scripts/checkpatch.pl
===================================================================
scripts/checkpatch.pl if ($#ARGV < 0) { · line 58
Quoted 6 lines
scripts/checkpatch.pl +1
-0@@ -53,6 +53,7 @@ if ($#ARGV < 0) { print " --file => check a source file\n"; print " --strict => enable more subjective tests\n"; print " --root => path to the kernel tree root\n"; + print "When patchfile is -, read standard input.\n"; exit(1); }
-apw
Re: [PATCH] checkpatch.pl: show how to read from stdin
Quoted 4 lines · Andy Whitcroft
Quoted 2 lines · Stefan Richter
Signed-off-by Stefan Richter <[email protected]>Acked-by Jiri Slaby <[email protected]>
Quoted 8 lines
As an absolute minimum this seems reasonable to me. I guess we could make no arguments default to '-' also. There are up and downsides to doing that, as currently no arguments currently tell you the usage and with this patch would point clearly out the '-' option. Just assuming stding would lose easy access to usage, which may actually be more confusing for the beginner. Hmmm. Cirtainly will include this documentation change if nothing else.
The patch that I submitted checks STDIN for piped data, and if there is any it will default to checking that incoming data .. That's regardless of the number of arguments given ..
Daniel
Re: [PATCH] checkpatch.pl: show how to read from stdin
Quoted 15 lines · Daniel Walker
Quoted 4 lines · Andy Whitcroft
Quoted 2 lines · Stefan Richter
Signed-off-by Stefan Richter <[email protected]>Acked-by Jiri Slaby <[email protected]>Quoted 8 lines
As an absolute minimum this seems reasonable to me. I guess we could make no arguments default to '-' also. There are up and downsides to doing that, as currently no arguments currently tell you the usage and with this patch would point clearly out the '-' option. Just assuming stding would lose easy access to usage, which may actually be more confusing for the beginner. Hmmm. Cirtainly will include this documentation change if nothing else.
Quoted 3 lines
The patch that I submitted checks STDIN for piped data, and if there is any it will default to checking that incoming data .. That's regardless of the number of arguments given ..
So it does, however that of itself differs from the unix norm; as with this I cannot run checkpatch and "type" (ie paste) a patch fragment to check it. So I don't think we want the semantics as you have there, as its confusing to the experienced user and inconsistent with the norm. Either we should document the standard '-' usage as has been suggested elsewhere or always assume stdin with no parameters.
-apw
Re: [PATCH] checkpatch.pl: show how to read from stdin
Quoted 7 lines · Andy Whitcroft
So it does, however that of itself differs from the unix norm; as with this I cannot run checkpatch and "type" (ie paste) a patch fragment to check it. So I don't think we want the semantics as you have there, as its confusing to the experienced user and inconsistent with the norm.
Either we should document the standard '-' usage as has been suggested elsewhere or always assume stdin with no parameters.
I'm not sure I understand what you mean .. Can you give an example?
Daniel
Re: [PATCH] checkpatch.pl: show how to read from stdin
Quoted 3 lines · Daniel Walker
Quoted 2 lines · Andy Whitcroft
with this I cannot run checkpatch and "type" (ie paste) a patch fragment to check it.
...
Quoted 1 line
I'm not sure I understand what you mean .. Can you give an example?
AFAIU Daniel's patch still leaves the possibility to use the '-' syntax, doesn't it?
(The program 'cat' is of the kind which always reads from stdin if no file name is given, or if '-' is given instead of a file name. So, 'cat' allows Andy to start it and then type something in for cat to process in either case, while checkpatch supports this only with '-' as argument. OTOH it's easier to get checkpatch to print a usage note than it is with cat. There you have to type no less than 'cat --help', or at least with GNU cat.)
Signature · 3 lines
Stefan Richter -=====-==--- ---= -===- http://arcgraph.de/sr/
Re: [PATCH] checkpatch.pl: show how to read from stdin
Quoted 2 lines · Stefan Richter
it is with cat. There you have to type no less than 'cat --help', or at least with GNU cat.)
--h (--he --hel --help) suffices due to getopt_long gnu implementation
Re: [PATCH] checkpatch.pl: show how to read from stdin
In reply to Stefan RichterQuoted 4 lines · Stefan Richter
AFAIU Daniel's patch still leaves the possibility to use the '-' syntax,
doesn't it?
Quoted 10 lines
(The program 'cat' is of the kind which always reads from stdin if no file name is given, or if '-' is given instead of a file name. So, 'cat' allows Andy to start it and then type something in for cat to process in either case, while checkpatch supports this only with '-' as
argument. OTOH it's easier to get checkpatch to print a usage note than
it is with cat. There you have to type no less than 'cat --help', or at
least with GNU cat.)
I tried the following with my changes,
./scripts/checkpatch.pl -
cat | ./scripts/checkpatch.pl
Both allowed pasting patches and pressing Ctrl-D , then it processed the patch..
and
cat <patchname> | ./scripts/checkpatch.pl
Also processed the patch ..
Daniel
Quoted 5 lines · Daniel Walker
Quoted 4 lines · Bernd Petrovitsch
Quoted 3 lines · Jiri Slaby
Quoted 2 lines · Daniel Walker
Quoted 1 line · Jiri Slaby
On 01/11/2008 05:10 AM, Daniel Walker wrote:
[...]
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
I was using it to do something like the following ,
git show
9914cad54c79d0b89b1f066c0894f00e1344131c|
./scripts/checkpatch.plQuoted 2 lines
Ok, and if you add a - there, it should have the same effect, but
for free,
Quoted 2 lines
doesn't it:
git show9914cad54c79d0b89b1f066c0894f00e1344131c
Quoted 8 lines
Quoted 6 lines
|
./scripts/checkpatch.pl-JftSoC:
git show9914cad54c79d0b89b1f066c0894f00e1344131c|./scripts/checkpatch.pl/dev/stdin
(and there a a few others) should also do the trick.Not a particularly attractive command line .. Might still be a good idea
Might be.
But it works for (almost?) all programs (which do not need seekable input) which absolutely want the input file specified by a parameter. And if it's an proprietary program, you can't even patch it.
Quoted 3 lines
to add this since these two forms alluded me, and are likely to allude people new to unix all together (who is more likely to be using this particular tool)..
Bernd
Signature · 3 lines
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services