[LEDE-DEV] Automated shell code debugging

Martin Tippmann mt at i3o.de
Fri Sep 30 15:11:23 PDT 2016


On Fri, Sep 30, 2016 at 11:36 PM, Jan-Tarek Butt <tarek at ring0.de> wrote:
> Hi thogeter,

Hi, not a dev - just my 2cents

> I have a realy nice idea :)
>
> As a part of code quallity enhancemend and prevenition. We can do an ondemand daemon as engine to
> check all shell scrips. We can use the opensource Project shellcheck [0].
>
> My idea is to do an insatnce on a server:
> This insatnce can pull the lede repo daily and run some thing like:
>
> find . -type f -name "*.sh" | xargs shellcheck
>
> if something news pulled and shellcheck detecs some misstating we can send via bsd-mailx
> on our ML the shellceck output.

shellcheck is a great tool but at least while tinkering with it on the
Weimarnetz firmware we found quite a few false positives and wrong
edge cases.

One thing we stumbled upon is that sometimes you want to use word
splitting for certain inputs and shellcheck always warns. There are a
lot of other issues that trigger unwarranted warnings:
https://github.com/koalaman/shellcheck/issues

I'm not a shell pro but I found it very difficult to impossible to
write something that passes without any hints/errors.

There is a way to avoid this by using special comments that prevent
shellcheck from nagging about the problem but this would pollute the
code with shellcheck specific comments.

Maybe using mail for the reports is too spammy due to the shortcomings
of shellcheck? Something like a generated HTML report[1] on a website
would be probably good enough/better?

But it's a great tool and catches a lot of issues and often
refactoring to make it happy results in better code but I'm not sure
if it's ready yet to mail reports.

shellcheck can also only check for a subset of problems[2] - maybe
there are some checks that are always right and could be useful to
warn about.

regards
Martin

1: https://github.com/koalaman/shellcheck/blob/master/shellcheck.1.md#user-content-formats
- looks like it's a good candidate?
2: shellcheck -e CODE1,CODE2..  --exclude=CODE1,CODE2..  exclude types
of warnings



More information about the Lede-dev mailing list