git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Add basic syntax check on shell scripts
@ 2012-12-02 13:17 Torsten Bögershausen
  2012-12-02 14:30 ` Stefano Lattarini
  2012-12-03 16:56 ` Junio C Hamano
  0 siblings, 2 replies; 11+ messages in thread
From: Torsten Bögershausen @ 2012-12-02 13:17 UTC (permalink / raw)
  To: git; +Cc: tboegi

The test suite needs to be run on different platforms.
As it may be difficult for contributors to catch syntax
which work on GNU/linux, but is unportable, make a quick check
for the most common problems.
"sed -i", "echo -n" or "array in shell scripts"
This list is not complete, and may need to be extended

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
We add 1 second test execution time
Is this a useful idea at all?
 
 t/t99999-syntax-check.sh | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100755 t/t99999-syntax-check.sh

diff --git a/t/t99999-syntax-check.sh b/t/t99999-syntax-check.sh
new file mode 100755
index 0000000..c4a9289
--- /dev/null
+++ b/t/t99999-syntax-check.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+test_description='Basic check if shell syntax is portable'
+
+. ./test-lib.sh
+
+
+test_expect_success 'No arrays in shell scripts' '
+	>expected &&
+	(grep -i -n "^[	 ]*declare[	 ][	 ]*" ../*.sh ../../git-* >actual 2>&1 || : ) &&
+	test_cmp expected actual &&
+	rm expected actual
+'
+
+test_expect_success 'No sed -i' '
+	>expected &&
+	(grep -n "^[	 ]*sed[	 ][	 ]*\-i" ../*.sh ../../git-* >actual 2>&1 || : ) &&
+	test_cmp expected actual &&
+	rm expected actual
+'
+
+test_expect_success 'No echo -n' '
+	>expected &&
+	(grep -n "^[	 ]*echo[	 ][	 ]*\-n" ../*.sh ../../git-* >actual 2>&1 || : ) &&
+	test_cmp expected actual &&
+	rm expected actual
+'
+test_done
-- 
1.8.0.197.g5a90748

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-12-05 16:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-02 13:17 [RFC] Add basic syntax check on shell scripts Torsten Bögershausen
2012-12-02 14:30 ` Stefano Lattarini
2012-12-03 16:56 ` Junio C Hamano
2012-12-04  7:20   ` Nguyen Thai Ngoc Duy
2012-12-04 19:39     ` Junio C Hamano
2012-12-05  5:43       ` Nguyen Thai Ngoc Duy
2012-12-05  6:02         ` Junio C Hamano
2012-12-05  7:30         ` Jeff King
2012-12-05  7:54           ` Jeff King
2012-12-05 16:12             ` Junio C Hamano
2012-12-05  9:11       ` Sebastian Schuberth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).