From: Stefano Lattarini <stefano.lattarini@gmail.com>
To: "Torsten Bögershausen" <tboegi@web.de>
Cc: git@vger.kernel.org
Subject: Re: [RFC] Add basic syntax check on shell scripts
Date: Sun, 02 Dec 2012 15:30:02 +0100 [thread overview]
Message-ID: <50BB65EA.5080805@gmail.com> (raw)
In-Reply-To: <201212021417.25525.tboegi@web.de>
On 12/02/2012 02:17 PM, Torsten Bögershausen wrote:
> 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?
>
FWIW, I think such an idea is useful (and also easy to implement,
so another +1 from me).
> 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 || : ) &&
>
Here I'd simply use:
! grep -n "^declare[ ][ ]*" ../*.sh ../../*.sh
And similarly for the tests below.
In addition, the globs above still miss some files ('perf/perf-lib.sh'
and 'valgrind/analyze.sh', for example); so we might want to improve
it, using, say, "git ls-files" (or find(1), in case the test is to be
run also from distribution tarballs).
HTH,
Stefano
next prev parent reply other threads:[~2012-12-02 14:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-02 13:17 [RFC] Add basic syntax check on shell scripts Torsten Bögershausen
2012-12-02 14:30 ` Stefano Lattarini [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50BB65EA.5080805@gmail.com \
--to=stefano.lattarini@gmail.com \
--cc=git@vger.kernel.org \
--cc=tboegi@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.