aboutsummaryrefslogtreecommitdiff
path: root/t/check-non-portable-shell.pl
Commit message (Collapse)AuthorAge
* test-lint: find unportable sed, echo, test, and export usage after &&Jonathan Nieder2014-05-23
| | | | | | | | | | | | | | | | | | | | | | | | Instead of anchoring these checks with "^\s*", just check that the usage is preceded by a word boundary. So now we can catch test $cond && export foo=bar just like we already catch test $cond && export foo=bar As a side effect, this will detect usage of "sed -i", "echo -n", "test a == b", and "export a=b" in comments. That is not ideal but it's potentially useful because people sometimes copy code from comments so it can be good to also avoid nonportable patterns there. To avoid false positives, keep the checks for 'declare' and 'which' anchored. Those are frequently used words in normal English-language comments. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* test-lint: detect 'export FOO=bar'Thomas Rast2013-07-08
| | | | | | | | | | | | Some shells do not understand the one-line construct, and instead need FOO=bar && export FOO Detect this in the test-lint target. Signed-off-by: Thomas Rast <trast@inf.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* test: Add check-non-portable-shell.plTorsten Bögershausen2013-01-02
Add the perl script "check-non-portable-shell.pl" to detect non-portable shell syntax. "echo -n" is an example of a shell command working on Linux, but not on Mac OS X. These shell commands are checked and reported as error: - "echo -n" (printf should be used) - "sed -i" (GNUism; use a temp file instead) - "declare" (bashism, often used with arrays) - "which" (unreliable exit status and output; use type instead) - "test a == b" (bashism for "test a = b") "make test-lint-shell-syntax" can be used to run only the check. Helped-By: Jeff King <peff@peff.net> Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>