From db8c7a1cc02e545dd75b55e2ccbab2de51cd06ae Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Mon, 13 Dec 2021 01:30:50 -0500 Subject: chainlint.sed: improve ?!AMP?! placement accuracy When chainlint.sed detects a broken &&-chain, it places an ?!AMP?! annotation at the beginning of the line. However, this is an unusual location for programmers accustomed to error messages (from compilers, for instance) indicating the exact point of the problem. Therefore, relocate the ?!AMP?! annotation to the end of the line in order to better direct the programmer's attention to the source of the problem. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/chainlint/nested-subshell-comment.expect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/chainlint/nested-subshell-comment.expect') diff --git a/t/chainlint/nested-subshell-comment.expect b/t/chainlint/nested-subshell-comment.expect index 15b68d4373..925e49bae9 100644 --- a/t/chainlint/nested-subshell-comment.expect +++ b/t/chainlint/nested-subshell-comment.expect @@ -6,6 +6,6 @@ # minor numbers of cows (or do they?) baz && snaff -?!AMP?!>> ) +>> ) ?!AMP?! fuzzy >) -- cgit v1.2.3 From 5be30d0cd301f50e5f4dd992bc11ce75f457cf46 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Mon, 13 Dec 2021 01:30:54 -0500 Subject: chainlint.sed: drop subshell-closing ">" annotation chainlint.sed inserts a ">" annotation at the beginning of a line to signal that its heuristics have identified an end-of-subshell. This was useful as a debugging aid during development of the script, but it has no value to test writers and might even confuse them into thinking that the linter is misbehaving by inserting line-noise into the shell code it is validating. Moreover, its presence also potentially makes it difficult to reuse the chainlint self-test "expect" output should a more capable linter ever be developed. Therefore, drop the ">" annotation. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/chainlint/nested-subshell-comment.expect | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/chainlint/nested-subshell-comment.expect') diff --git a/t/chainlint/nested-subshell-comment.expect b/t/chainlint/nested-subshell-comment.expect index 925e49bae9..9138cf386d 100644 --- a/t/chainlint/nested-subshell-comment.expect +++ b/t/chainlint/nested-subshell-comment.expect @@ -6,6 +6,6 @@ # minor numbers of cows (or do they?) baz && snaff ->> ) ?!AMP?! + ) ?!AMP?! fuzzy ->) +) -- cgit v1.2.3 From 31da22d1fd46e80c592f6b04c6cafdb983c8a903 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Mon, 13 Dec 2021 01:30:58 -0500 Subject: chainlint.sed: swallow comments consistently When checking for broken a &&-chain, chainlint.sed knows that the final statement in a subshell should not end with `&&`, so it takes care to make a distinction between the final line which is an actual statement and any lines which may be mere comments preceding the closing ')'. As such, it swallows comment lines so that they do not interfere with the &&-chain check. However, since `sed` does not provide any sort of real recursion, chainlint.sed only checks &&-chains in subshells one level deep; it doesn't do any checking in deeper subshells or in `{...}` blocks within subshells. Furthermore, on account of potential implementation complexity, it doesn't check &&-chains within `case` arms. Due to an oversight, it also doesn't swallow comments inside deep subshells, `{...}` blocks, or `case` statements, which makes its output inconsistent (swallowing comments in some cases but not others). Unfortunately, this inconsistency seeps into the chainlint self-test "expect" files, which potentially makes it difficult to reuse the self-tests should a more capable chainlint ever be developed. Therefore, teach chainlint.sed to consistently swallow comments in all cases. Signed-off-by: Eric Sunshine Signed-off-by: Junio C Hamano --- t/chainlint/nested-subshell-comment.expect | 2 -- 1 file changed, 2 deletions(-) (limited to 't/chainlint/nested-subshell-comment.expect') diff --git a/t/chainlint/nested-subshell-comment.expect b/t/chainlint/nested-subshell-comment.expect index 9138cf386d..be4b27a305 100644 --- a/t/chainlint/nested-subshell-comment.expect +++ b/t/chainlint/nested-subshell-comment.expect @@ -2,8 +2,6 @@ foo && ( bar && - # bottles wobble while fiddles gobble - # minor numbers of cows (or do they?) baz && snaff ) ?!AMP?! -- cgit v1.2.3