test: Add check-non-portable-shell.pl
commitc7ce70ace9794a8f0b4774d803536a7ecdf318de
authorTorsten Bögershausen <tboegi@web.de>
Wed, 2 Jan 2013 23:20:19 +0000 (3 00:20 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Jan 2013 00:06:42 +0000 (2 16:06 -0800)
tree984a46565e24ffc9f8ca12c83e31817077abbc0c
parent5d417842efeafb6e109db7574196901c4e95d273
test: Add check-non-portable-shell.pl

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>
t/Makefile
t/check-non-portable-shell.pl [new file with mode: 0755]