Re: [RFC] Add basic syntax check on shell scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nguyen Thai Ngoc Duy <pclouds@xxxxxxxxx> writes:

>> This (once it gets cleaned up to reduce false positives) belongs to
>> "cd t && make test-lint".
>
> Or a project commit hook?

Surely.  It is OK to have "cd t && make test-lint" in your
pre-commit hook.

A few more things in addition to what Torsten's script attempts to
catch that we would want to catch are:

 * Do not spell string equality with "test $a == $b"; that is
   bash-ism and you only need "=" (which works in bash, too);

 * Do not capture output from "wc -l" in a variable and string
   compare with a constant, e.g. 

	lnum=$(wc -l <...) && test "$lnum" = 9

   as some wc implementations place extra SP in its output;

 * Do not use "test_must_fail" to run non-git command and require it
   to fail (instead, just write "! cmd").

 * Do not write ERE with backslashes and expect "grep" to grok them;
   that's GNUism.  e.g.

	grep "^\(author\|committer\) "

   is bad.  Use egrep (or "grep -E") if you want to use ERE.


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]