[Linux-kernel-mentees] [PATCH] checkpatch: Warn about missing shebang in scripts
Mrinal Pandey
mrinalmni at gmail.com
Fri Jul 24 04:59:27 UTC 2020
On Wed, Jul 22, 2020 at 3:53 PM Lukas Bulwahn <lukas.bulwahn at gmail.com>
wrote:
>
>
> On Tue, 21 Jul 2020, Mrinal Pandey wrote:
>
> > checkpatch should warn if a script doesn't seem to have a shebang in the
> > first line. There is no such check present currently.
> >
> > Issue this warning by checking if the file is a script and checking
> > `$realline` to be `1`, i.e. the first line. If these conditions are
> > satisfied and the first line is not a shebang, issue a missing or
> > mispaced shebang warning.
> >
> > Signed-off-by: Mrinal Pandey <mrinalmni at gmail.com>
> > ---
> > scripts/checkpatch.pl | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 4c820607540b..c79233c64cee 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -3165,6 +3165,13 @@ sub process {
> > }
> > }
> >
> > +# check for missing shebang in scripts
> > + if ($realline == 1 && $realfile =~
> /.*\.\(py\|sh\|pl\|awk\|tc\|yaml\)/) {
>
> yaml files do not have a shebang...
>
Sir,
Yes, I will remove that from the list.
>
> This whole check can probably placed elsewhere better.
>
Should I place it on line 2657 as the check just above it also deals with
scripts?
>
> > + if ($rawline !~ /^[ \+]\s*\#\!\s*\//) {
> > + WARN("MISSING_SHEBANG", "Missing or
> misplaced shebang for '$realfile'");
> > + }
> > + }
> > +
> > # check for using SPDX license tag at beginning of files
> > if ($realline == $checklicenseline) {
> > if ($rawline =~ /^[ \+]\s*\#\!\s*\//) {
> > --
> > 2.25.1
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/linux-kernel-mentees/attachments/20200724/70c43d9c/attachment.html>
More information about the Linux-kernel-mentees
mailing list