ebcbbe060f
The --chain-lint option uses heuristics and knowledge of shell syntax to detect broken &&-chains in subshells by pure textual inspection. The heuristics handle a range of stylistic variations in existing tests (evolved over the years), however, they are still best-guesses. As such, it is possible for future changes to accidentally break assumptions upon which the heuristics are based. Protect against this possibility by adding tests which check the linter itself for correctness. In addition to protecting against regressions, these tests help document (for humans) expected behavior, which is important since the linter's implementation language ('sed') does not necessarily lend itself to easy comprehension. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
29 lines
523 B
Plaintext
29 lines
523 B
Plaintext
(
|
|
# LINT: 'if', 'then', 'elif', 'else', 'fi' do not need "&&"
|
|
if test -n ""
|
|
then
|
|
# LINT: missing "&&" on 'echo'
|
|
echo very
|
|
# LINT: last statement before 'elif' does not need "&&"
|
|
echo empty
|
|
elif test -z ""
|
|
# LINT: last statement before 'else' does not need "&&"
|
|
echo foo
|
|
else
|
|
echo foo &&
|
|
# LINT: last statement before 'fi' does not need "&&"
|
|
cat <<-\EOF
|
|
bar
|
|
EOF
|
|
# LINT: missing "&&" on 'fi'
|
|
fi
|
|
echo poodle
|
|
) &&
|
|
(
|
|
# LINT: 'then' on same line as 'if'
|
|
if test -n ""; then
|
|
echo very &&
|
|
echo empty
|
|
if
|
|
)
|