Package: check-all-the-things
Version: 2015.12.10
Severity: normal
Tags: patch

Hello,

currently, checkbashisms and shellcheck only look for files ending in '.sh'.
However, there are people who believe that executables should not be named
after the language in which they're currently implemented. For example, there
is "check-all-the-things" but not "check-all-the-things.py". Personally, I
advocate this, but for this report it only matters that a significant portion
of scripts does not end in '.sh'.

Using the existing syntax of catt, it's rather easy to extend the checks, and
filter by "file | grep | cat". Please see below for example runs on some
project I'm working on.

Impact:
- positive->negative can only occur for files whose name end in '.sh' but are
not shell scripts. I consider this a good thing, but I'm not sure why this
would ever happen.
- negative->positive can only occur for files whose name does NOT end in '.sh',
but ARE shell scripts, and DO trigger warnings/errors in the linting tools.
That's the point of this patch, so it's a good thing, too.

Is there a linter for the checks?
Should I adapt other checks, too?
In how far does this affect #791722, which seems to revolve mostly around
python scripts?

Cheers,
Ben Wiederhake



user@machine:~/workspace/telegram-purple$ # Run installed, non-patched version
on some project
user@machine:~/workspace/telegram-purple$ check-all-the-things --checks
=checkbashisms --checks +shellcheck
Skipped and hidden checks:
- cmdline disabled check: 7z-test acheck ansible-lint appstream-util-validate
appstreamcli-validate bashate bfbtester ...
- dangerous check: bfbtester perl-b-lint perl-syntax-check
- help needed: acheck ansible-lint appstream-util-validate appstreamcli-
validate build-log-scanner cbmc chk-origtargz ...
- no matching files: 7z-test bfbtester blhc build-log-errors build-log-warnings
bzip2-test cabal chk-origtargz ...
- no output: checkbashisms shellcheck



user@machine:~/workspace/telegram-purple$ # Run local, patched version on some
project
user@machine:~/workspace/telegram-purple$ ../check-all-the-things/check-all-
the-things --checks =checkbashisms --checks +shellcheck
$ find \( -name .git -o -name .svn -o -name .bzr -o -name CVS -o -name .hg -o
-name _darcs -o -name _FOSSIL_ -o -name .sgdrawer -o -name configure -o -name
config.status -o -name config.sub -o -name config.guess -o -name install-sh -o
-name install.sh \) -prune -o -type f -print0 | xargs -0 file -F "   " -N |
grep -a 'shell script' | cut -f 1 | xargs -d"\n" --no-run-if-empty
checkbashisms
possible bashism in ./commit.h.gen line 23 ('command' with option other than
-p):
if ! (command -v git && git status) >/dev/null 2>&1

$ find \( -name .git -o -name .svn -o -name .bzr -o -name CVS -o -name .hg -o
-name _darcs -o -name _FOSSIL_ -o -name .sgdrawer -o -name configure -o -name
config.status -o -name config.sub -o -name config.guess -o -name install-sh -o
-name install.sh \) -prune -o -type f -print0 | xargs -0 file -F "   " -N |
grep -a 'shell script' | cut -f 1 | xargs -d"\n" --no-run-if-empty shellcheck

In ./commit.h.gen line 35:
GIT_COMMIT=`git rev-parse HEAD | cut -c1-10`
           ^-- SC2006: Use $(..) instead of legacy `..`.

In ./gen-origtar line 47:
TARNAME="telegram-purple_`git describe --tags | sed s/^v// `.orig.tar.gz"
                         ^-- SC2006: Use $(..) instead of legacy `..`.

In ./gen-origtar line 49:
echo mv -f bin/result.tar.gz $TARNAME
                             ^-- SC2086: Double quote to prevent globbing and
word splitting.

In ./gen-origtar line 50:
mv -f bin/result.tar.gz $TARNAME
                        ^-- SC2086: Double quote to prevent globbing and word
splitting.

Skipped and hidden checks:
- cmdline disabled check: 7z-test acheck afl ansible-lint appstream-util-
validate appstreamcli-validate autodep8 bashate ...
- dangerous check: bfbtester perl-b-lint perl-syntax-check
- help needed: acheck ansible-lint cbmc checkmp3 chk-origtargz clang-check
clang-tidy cppclean doc8 embedding-restrictions ...
- no matching files: 7z-test acheck afl ansible-lint appstream-util-validate
appstreamcli-validate autodep8 bashate ...
>From 7f782a324333fce427d2369b7ec96ae99f61f8c5 Mon Sep 17 00:00:00 2001
From: Ben Wiederhake <benwiederhake.git...@gmx.de>
Date: Thu, 10 Mar 2016 12:11:54 +0100
Subject: [PATCH] Improve detection of shell scripts

Affects [checkbashisms] and [shellcheck]
---
 data/sh | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/data/sh b/data/sh
index 2389117..32469e6 100644
--- a/data/sh
+++ b/data/sh
@@ -4,13 +4,23 @@ command = sh -n {file}
 
 [checkbashisms]
 apt = devscripts
-files = *.sh
-command = checkbashisms {files}
+# TODO: replace not-dirs with --ignore option
+not-dirs = .git .svn .bzr CVS .hg _darcs _FOSSIL_ .sgdrawer
+# TODO: replace not-files with recursive option (#780197)
+not-files =
+ configure config.status config.sub config.guess install-sh install.sh
+# Careful: file -F "<LITERAL_TAB>" ... cut -d "<LITERAL_TAB>"
+command = file -F "	" -N {files} | grep -a 'shell script' | cut -f 1 -d "	" | xargs -d"\n" --no-run-if-empty checkbashisms
 
 [shellcheck]
 apt = shellcheck
-files = *.sh *.bash *.zsh
-command = shellcheck {files}
+# TODO: replace not-dirs with --ignore option
+not-dirs = .git .svn .bzr CVS .hg _darcs _FOSSIL_ .sgdrawer
+# TODO: replace not-files with recursive option (#780197)
+not-files =
+ configure config.status config.sub config.guess install-sh install.sh
+# Careful: file -F "<LITERAL_TAB>" ... cut -d "<LITERAL_TAB>"
+command = file -F "	" -N {files} | grep -a 'shell script' | cut -f 1 -d "	" | xargs -d"\n" --no-run-if-empty shellcheck
 
 [bashate]
 apt = python3-bashate | python-bashate
-- 
2.7.0

Reply via email to