]> granicus.if.org Git - zfs/commitdiff
Style check shell scripts
authorTurbo Fredriksson <turbo@bayour.com>
Mon, 18 May 2015 18:49:24 +0000 (20:49 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 20 May 2015 21:10:03 +0000 (14:10 -0700)
If the command "shellcheck" exists, then find all shell scripts and
run shellcheck on them.
* Use 'gcc' format with shellcheck.
* Exclude zfs-script-config.sh (which isn't really a script).

Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3428

Makefile.am

index 49b417a81d9e6ec5c090f37a6f9901e3d3d6eaf3..788122d2aac9738d8355a04e4fd72b3fa02b4b11 100644 (file)
@@ -40,10 +40,22 @@ dist-hook:
        sed -i 's/Release:[[:print:]]*/Release:      $(RELEASE)/' \
                $(distdir)/META
 
-checkstyle:
+checkstyle: cstyle shellcheck
+
+cstyle:
        @find ${top_srcdir} -name '*.[hc]' ! -name 'zfs_config.*' \
                ! -name '*.mod.c' -type f -exec scripts/cstyle.pl {} \+
 
+shellcheck:
+       @if type shellcheck > /dev/null 2>&1; then \
+               (find ${top_srcdir} -type f -name '*.sh.in' -o -type f \
+                -name '*.sh'; find etc/init.d/zfs*.in -type f) | \
+                grep -v 'zfs-script-config' | \
+                while read file; do \
+                       shellcheck --format gcc "$$file"; \
+                done; \
+        fi
+
 ctags:
        $(RM) $(top_srcdir)/tags
        find $(top_srcdir) -name .git -prune -o -name '*.[hc]' | xargs ctags