git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 3, 2012, 16:56 UTC
Message-ID
<7vzk1vrs63.fsf@alter.siamese.dyndns.org>
In-Reply-To
<201212021417.25525.tboegi@web.de>
Torsten Bögershausen <tboegi@web.de> writes:
Show 11 quoted lines
> 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?

Please do not name it after t/t[0-9]*.sh pattern, which are about testing git.

This (once it gets cleaned up to reduce false positives) belongs to "cd t && make test-lint".

Show 39 quoted lines
>  
>  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
Previous: Stefano LattariniNext: Nguyen Thai Ngoc Duy
Message 3 of 11 in “[RFC] Add basic syntax check on shell scripts”
  1. Torsten BögershausenDec 2, 2012
  2. Stefano LattariniDec 2, 2012
  3. Junio C HamanoDec 3, 2012
  4. Nguyen Thai Ngoc DuyDec 4, 2012
  5. Junio C HamanoDec 4, 2012
  6. Nguyen Thai Ngoc DuyDec 5, 2012
  7. Junio C HamanoDec 5, 2012
  8. Jeff KingDec 5, 2012
  9. Jeff KingDec 5, 2012
  10. Junio C HamanoDec 5, 2012
  11. Sebastian SchuberthDec 5, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.