Squashed 'third_party/git/' content from commit cb71568594
git-subtree-dir: third_party/git git-subtree-split: cb715685942260375e1eb8153b0768a376e4ece7
This commit is contained in:
commit
1b593e1ea4
3629 changed files with 1139935 additions and 0 deletions
9
t/chainlint/arithmetic-expansion.expect
Normal file
9
t/chainlint/arithmetic-expansion.expect
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(
|
||||
foo &&
|
||||
bar=$((42 + 1)) &&
|
||||
baz
|
||||
>) &&
|
||||
(
|
||||
?!AMP?! bar=$((42 + 1))
|
||||
baz
|
||||
>)
|
||||
11
t/chainlint/arithmetic-expansion.test
Normal file
11
t/chainlint/arithmetic-expansion.test
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(
|
||||
foo &&
|
||||
# LINT: closing ")" of $((...)) not misinterpreted as subshell-closing ")"
|
||||
bar=$((42 + 1)) &&
|
||||
baz
|
||||
) &&
|
||||
(
|
||||
# LINT: missing "&&" on $((...))
|
||||
bar=$((42 + 1))
|
||||
baz
|
||||
)
|
||||
10
t/chainlint/bash-array.expect
Normal file
10
t/chainlint/bash-array.expect
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(
|
||||
foo &&
|
||||
bar=(gumbo stumbo wumbo) &&
|
||||
baz
|
||||
>) &&
|
||||
(
|
||||
foo &&
|
||||
bar=${#bar[@]} &&
|
||||
baz
|
||||
>)
|
||||
12
t/chainlint/bash-array.test
Normal file
12
t/chainlint/bash-array.test
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(
|
||||
foo &&
|
||||
# LINT: ")" in Bash array assignment not misinterpreted as subshell-closing ")"
|
||||
bar=(gumbo stumbo wumbo) &&
|
||||
baz
|
||||
) &&
|
||||
(
|
||||
foo &&
|
||||
# LINT: Bash array length operator not misinterpreted as comment
|
||||
bar=${#bar[@]} &&
|
||||
baz
|
||||
)
|
||||
4
t/chainlint/blank-line.expect
Normal file
4
t/chainlint/blank-line.expect
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(
|
||||
nothing &&
|
||||
something
|
||||
>)
|
||||
10
t/chainlint/blank-line.test
Normal file
10
t/chainlint/blank-line.test
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(
|
||||
|
||||
nothing &&
|
||||
|
||||
something
|
||||
# LINT: swallow blank lines since final _statement_ before subshell end is
|
||||
# LINT: significant to "&&"-check, not final _line_ (which might be blank)
|
||||
|
||||
|
||||
)
|
||||
12
t/chainlint/block.expect
Normal file
12
t/chainlint/block.expect
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(
|
||||
foo &&
|
||||
{
|
||||
echo a
|
||||
echo b
|
||||
} &&
|
||||
bar &&
|
||||
{
|
||||
echo c
|
||||
?!AMP?! }
|
||||
baz
|
||||
>)
|
||||
15
t/chainlint/block.test
Normal file
15
t/chainlint/block.test
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(
|
||||
# LINT: missing "&&" in block not currently detected (for consistency with
|
||||
# LINT: --chain-lint at top level and to provide escape hatch if needed)
|
||||
foo &&
|
||||
{
|
||||
echo a
|
||||
echo b
|
||||
} &&
|
||||
bar &&
|
||||
# LINT: missing "&&" at closing "}"
|
||||
{
|
||||
echo c
|
||||
}
|
||||
baz
|
||||
)
|
||||
6
t/chainlint/broken-chain.expect
Normal file
6
t/chainlint/broken-chain.expect
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(
|
||||
foo &&
|
||||
?!AMP?! bar
|
||||
baz &&
|
||||
wop
|
||||
>)
|
||||
8
t/chainlint/broken-chain.test
Normal file
8
t/chainlint/broken-chain.test
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(
|
||||
foo &&
|
||||
# LINT: missing "&&" from 'bar'
|
||||
bar
|
||||
baz &&
|
||||
# LINT: final statement before closing ")" legitimately lacks "&&"
|
||||
wop
|
||||
)
|
||||
19
t/chainlint/case.expect
Normal file
19
t/chainlint/case.expect
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(
|
||||
case "$x" in
|
||||
x) foo ;;
|
||||
*) bar ;;
|
||||
esac &&
|
||||
foobar
|
||||
>) &&
|
||||
(
|
||||
case "$x" in
|
||||
x) foo ;;
|
||||
*) bar ;;
|
||||
?!AMP?! esac
|
||||
foobar
|
||||
>) &&
|
||||
(
|
||||
case "$x" in 1) true;; esac &&
|
||||
?!AMP?! case "$y" in 2) false;; esac
|
||||
foobar
|
||||
>)
|
||||
23
t/chainlint/case.test
Normal file
23
t/chainlint/case.test
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
(
|
||||
# LINT: "...)" arms in 'case' not misinterpreted as subshell-closing ")"
|
||||
case "$x" in
|
||||
x) foo ;;
|
||||
*) bar ;;
|
||||
esac &&
|
||||
foobar
|
||||
) &&
|
||||
(
|
||||
# LINT: missing "&&" on 'esac'
|
||||
case "$x" in
|
||||
x) foo ;;
|
||||
*) bar ;;
|
||||
esac
|
||||
foobar
|
||||
) &&
|
||||
(
|
||||
# LINT: "...)" arm in one-liner 'case' not misinterpreted as closing ")"
|
||||
case "$x" in 1) true;; esac &&
|
||||
# LINT: same but missing "&&"
|
||||
case "$y" in 2) false;; esac
|
||||
foobar
|
||||
)
|
||||
4
t/chainlint/close-nested-and-parent-together.expect
Normal file
4
t/chainlint/close-nested-and-parent-together.expect
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(
|
||||
cd foo &&
|
||||
(bar &&
|
||||
>>> baz))
|
||||
3
t/chainlint/close-nested-and-parent-together.test
Normal file
3
t/chainlint/close-nested-and-parent-together.test
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(cd foo &&
|
||||
(bar &&
|
||||
baz))
|
||||
25
t/chainlint/close-subshell.expect
Normal file
25
t/chainlint/close-subshell.expect
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
(
|
||||
foo
|
||||
>) &&
|
||||
(
|
||||
bar
|
||||
>) >out &&
|
||||
(
|
||||
baz
|
||||
>) 2>err &&
|
||||
(
|
||||
boo
|
||||
>) <input &&
|
||||
(
|
||||
bip
|
||||
>) | wuzzle &&
|
||||
(
|
||||
bop
|
||||
>) | fazz fozz &&
|
||||
(
|
||||
bup
|
||||
>) |
|
||||
fuzzle &&
|
||||
(
|
||||
yop
|
||||
>)
|
||||
27
t/chainlint/close-subshell.test
Normal file
27
t/chainlint/close-subshell.test
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# LINT: closing ")" with various decorations ("&&", ">", "|", etc.)
|
||||
(
|
||||
foo
|
||||
) &&
|
||||
(
|
||||
bar
|
||||
) >out &&
|
||||
(
|
||||
baz
|
||||
) 2>err &&
|
||||
(
|
||||
boo
|
||||
) <input &&
|
||||
(
|
||||
bip
|
||||
) | wuzzle &&
|
||||
(
|
||||
bop
|
||||
) | fazz \
|
||||
fozz &&
|
||||
(
|
||||
bup
|
||||
) |
|
||||
fuzzle &&
|
||||
(
|
||||
yop
|
||||
)
|
||||
9
t/chainlint/command-substitution.expect
Normal file
9
t/chainlint/command-substitution.expect
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(
|
||||
foo &&
|
||||
bar=$(gobble) &&
|
||||
baz
|
||||
>) &&
|
||||
(
|
||||
?!AMP?! bar=$(gobble blocks)
|
||||
baz
|
||||
>)
|
||||
11
t/chainlint/command-substitution.test
Normal file
11
t/chainlint/command-substitution.test
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(
|
||||
foo &&
|
||||
# LINT: closing ")" of $(...) not misinterpreted as subshell-closing ")"
|
||||
bar=$(gobble) &&
|
||||
baz
|
||||
) &&
|
||||
(
|
||||
# LINT: missing "&&" on $(...)
|
||||
bar=$(gobble blocks)
|
||||
baz
|
||||
)
|
||||
4
t/chainlint/comment.expect
Normal file
4
t/chainlint/comment.expect
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(
|
||||
nothing &&
|
||||
something
|
||||
>)
|
||||
11
t/chainlint/comment.test
Normal file
11
t/chainlint/comment.test
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(
|
||||
# LINT: swallow comment lines
|
||||
# comment 1
|
||||
nothing &&
|
||||
# comment 2
|
||||
something
|
||||
# LINT: swallow comment lines since final _statement_ before subshell end is
|
||||
# LINT: significant to "&&"-check, not final _line_ (which might be comment)
|
||||
# comment 3
|
||||
# comment 4
|
||||
)
|
||||
10
t/chainlint/complex-if-in-cuddled-loop.expect
Normal file
10
t/chainlint/complex-if-in-cuddled-loop.expect
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(
|
||||
for i in a b c; do
|
||||
if test "$(echo $(waffle bat))" = "eleventeen" &&
|
||||
test "$x" = "$y"; then
|
||||
:
|
||||
else
|
||||
echo >file
|
||||
fi
|
||||
> done) &&
|
||||
test ! -f file
|
||||
11
t/chainlint/complex-if-in-cuddled-loop.test
Normal file
11
t/chainlint/complex-if-in-cuddled-loop.test
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# LINT: 'for' loop cuddled with "(" and ")" and nested 'if' with complex
|
||||
# LINT: multi-line condition; indented with spaces, not tabs
|
||||
(for i in a b c; do
|
||||
if test "$(echo $(waffle bat))" = "eleventeen" &&
|
||||
test "$x" = "$y"; then
|
||||
:
|
||||
else
|
||||
echo >file
|
||||
fi
|
||||
done) &&
|
||||
test ! -f file
|
||||
7
t/chainlint/cuddled-if-then-else.expect
Normal file
7
t/chainlint/cuddled-if-then-else.expect
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(
|
||||
if test -z ""; then
|
||||
echo empty
|
||||
else
|
||||
echo bizzy
|
||||
> fi) &&
|
||||
echo foobar
|
||||
7
t/chainlint/cuddled-if-then-else.test
Normal file
7
t/chainlint/cuddled-if-then-else.test
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# LINT: 'if' cuddled with "(" and ")"; indented with spaces, not tabs
|
||||
(if test -z ""; then
|
||||
echo empty
|
||||
else
|
||||
echo bizzy
|
||||
fi) &&
|
||||
echo foobar
|
||||
5
t/chainlint/cuddled-loop.expect
Normal file
5
t/chainlint/cuddled-loop.expect
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(
|
||||
while read x
|
||||
do foobar bop || exit 1
|
||||
> done <file ) &&
|
||||
outside subshell
|
||||
7
t/chainlint/cuddled-loop.test
Normal file
7
t/chainlint/cuddled-loop.test
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# LINT: 'while' loop cuddled with "(" and ")", with embedded (allowed)
|
||||
# LINT: "|| exit {n}" to exit loop early, and using redirection "<" to feed
|
||||
# LINT: loop; indented with spaces, not tabs
|
||||
( while read x
|
||||
do foobar bop || exit 1
|
||||
done <file ) &&
|
||||
outside subshell
|
||||
21
t/chainlint/cuddled.expect
Normal file
21
t/chainlint/cuddled.expect
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
(
|
||||
cd foo &&
|
||||
bar
|
||||
>) &&
|
||||
|
||||
(
|
||||
?!AMP?!cd foo
|
||||
bar
|
||||
>) &&
|
||||
|
||||
(
|
||||
cd foo &&
|
||||
> bar) &&
|
||||
|
||||
(
|
||||
cd foo &&
|
||||
> bar) &&
|
||||
|
||||
(
|
||||
?!AMP?!cd foo
|
||||
> bar)
|
||||
23
t/chainlint/cuddled.test
Normal file
23
t/chainlint/cuddled.test
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# LINT: first subshell statement cuddled with opening "("; for implementation
|
||||
# LINT: simplicity, "(..." is split into two lines, "(" and "..."
|
||||
(cd foo &&
|
||||
bar
|
||||
) &&
|
||||
|
||||
# LINT: same with missing "&&"
|
||||
(cd foo
|
||||
bar
|
||||
) &&
|
||||
|
||||
# LINT: closing ")" cuddled with final subshell statement
|
||||
(
|
||||
cd foo &&
|
||||
bar) &&
|
||||
|
||||
# LINT: "(" and ")" cuddled with first and final subshell statements
|
||||
(cd foo &&
|
||||
bar) &&
|
||||
|
||||
# LINT: same with missing "&&"
|
||||
(cd foo
|
||||
bar)
|
||||
24
t/chainlint/exit-loop.expect
Normal file
24
t/chainlint/exit-loop.expect
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
(
|
||||
for i in a b c
|
||||
do
|
||||
foo || exit 1
|
||||
bar &&
|
||||
baz
|
||||
done
|
||||
>) &&
|
||||
(
|
||||
while true
|
||||
do
|
||||
foo || exit 1
|
||||
bar &&
|
||||
baz
|
||||
done
|
||||
>) &&
|
||||
(
|
||||
i=0 &&
|
||||
while test $i -lt 10
|
||||
do
|
||||
echo $i || exit
|
||||
i=$(($i + 1))
|
||||
done
|
||||
>)
|
||||
27
t/chainlint/exit-loop.test
Normal file
27
t/chainlint/exit-loop.test
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
(
|
||||
for i in a b c
|
||||
do
|
||||
# LINT: "|| exit {n}" valid for-loop escape in subshell; no "&&" needed
|
||||
foo || exit 1
|
||||
bar &&
|
||||
baz
|
||||
done
|
||||
) &&
|
||||
(
|
||||
while true
|
||||
do
|
||||
# LINT: "|| exit {n}" valid while-loop escape in subshell; no "&&" needed
|
||||
foo || exit 1
|
||||
bar &&
|
||||
baz
|
||||
done
|
||||
) &&
|
||||
(
|
||||
i=0 &&
|
||||
while test $i -lt 10
|
||||
do
|
||||
# LINT: "|| exit" (sans exit code) valid escape in subshell; no "&&" needed
|
||||
echo $i || exit
|
||||
i=$(($i + 1))
|
||||
done
|
||||
)
|
||||
5
t/chainlint/exit-subshell.expect
Normal file
5
t/chainlint/exit-subshell.expect
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(
|
||||
foo || exit 1
|
||||
bar &&
|
||||
baz
|
||||
>)
|
||||
6
t/chainlint/exit-subshell.test
Normal file
6
t/chainlint/exit-subshell.test
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(
|
||||
# LINT: "|| exit {n}" valid subshell escape without hurting &&-chain
|
||||
foo || exit 1
|
||||
bar &&
|
||||
baz
|
||||
)
|
||||
11
t/chainlint/for-loop.expect
Normal file
11
t/chainlint/for-loop.expect
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(
|
||||
for i in a b c
|
||||
do
|
||||
?!AMP?! echo $i
|
||||
cat
|
||||
?!AMP?! done
|
||||
for i in a b c; do
|
||||
echo $i &&
|
||||
cat $i
|
||||
done
|
||||
>)
|
||||
19
t/chainlint/for-loop.test
Normal file
19
t/chainlint/for-loop.test
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(
|
||||
# LINT: 'for', 'do', 'done' do not need "&&"
|
||||
for i in a b c
|
||||
do
|
||||
# LINT: missing "&&" on 'echo'
|
||||
echo $i
|
||||
# LINT: last statement of while does not need "&&"
|
||||
cat <<-\EOF
|
||||
bar
|
||||
EOF
|
||||
# LINT: missing "&&" on 'done'
|
||||
done
|
||||
|
||||
# LINT: 'do' on same line as 'for'
|
||||
for i in a b c; do
|
||||
echo $i &&
|
||||
cat $i
|
||||
done
|
||||
)
|
||||
2
t/chainlint/here-doc-close-subshell.expect
Normal file
2
t/chainlint/here-doc-close-subshell.expect
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(
|
||||
> cat)
|
||||
5
t/chainlint/here-doc-close-subshell.test
Normal file
5
t/chainlint/here-doc-close-subshell.test
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(
|
||||
# LINT: line contains here-doc and closes nested subshell
|
||||
cat <<-\INPUT)
|
||||
fizz
|
||||
INPUT
|
||||
5
t/chainlint/here-doc-multi-line-command-subst.expect
Normal file
5
t/chainlint/here-doc-multi-line-command-subst.expect
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(
|
||||
x=$(bobble &&
|
||||
?!AMP?!>> wiffle)
|
||||
echo $x
|
||||
>)
|
||||
9
t/chainlint/here-doc-multi-line-command-subst.test
Normal file
9
t/chainlint/here-doc-multi-line-command-subst.test
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(
|
||||
# LINT: line contains here-doc and opens multi-line $(...)
|
||||
x=$(bobble <<-\END &&
|
||||
fossil
|
||||
vegetable
|
||||
END
|
||||
wiffle)
|
||||
echo $x
|
||||
)
|
||||
4
t/chainlint/here-doc-multi-line-string.expect
Normal file
4
t/chainlint/here-doc-multi-line-string.expect
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(
|
||||
?!AMP?! cat && echo "multi-line string"
|
||||
bap
|
||||
>)
|
||||
8
t/chainlint/here-doc-multi-line-string.test
Normal file
8
t/chainlint/here-doc-multi-line-string.test
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(
|
||||
# LINT: line contains here-doc and opens multi-line string
|
||||
cat <<-\TXT && echo "multi-line
|
||||
string"
|
||||
fizzle
|
||||
TXT
|
||||
bap
|
||||
)
|
||||
9
t/chainlint/here-doc.expect
Normal file
9
t/chainlint/here-doc.expect
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
boodle wobba gorgo snoot wafta snurb &&
|
||||
|
||||
cat >foo &&
|
||||
|
||||
cat >bar &&
|
||||
|
||||
cat >boo &&
|
||||
|
||||
horticulture
|
||||
37
t/chainlint/here-doc.test
Normal file
37
t/chainlint/here-doc.test
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# LINT: stitch together incomplete \-ending lines
|
||||
# LINT: swallow here-doc to avoid false positives in content
|
||||
boodle wobba \
|
||||
gorgo snoot \
|
||||
wafta snurb <<EOF &&
|
||||
quoth the raven,
|
||||
nevermore...
|
||||
EOF
|
||||
|
||||
# LINT: swallow here-doc with arbitrary tag
|
||||
cat <<-Arbitrary_Tag_42 >foo &&
|
||||
snoz
|
||||
boz
|
||||
woz
|
||||
Arbitrary_Tag_42
|
||||
|
||||
# LINT: swallow 'quoted' here-doc
|
||||
cat <<'FUMP' >bar &&
|
||||
snoz
|
||||
boz
|
||||
woz
|
||||
FUMP
|
||||
|
||||
# LINT: swallow "quoted" here-doc
|
||||
cat <<"zump" >boo &&
|
||||
snoz
|
||||
boz
|
||||
woz
|
||||
zump
|
||||
|
||||
# LINT: swallow here-doc (EOF is last line of test)
|
||||
horticulture <<\EOF
|
||||
gomez
|
||||
morticia
|
||||
wednesday
|
||||
pugsly
|
||||
EOF
|
||||
12
t/chainlint/if-in-loop.expect
Normal file
12
t/chainlint/if-in-loop.expect
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(
|
||||
for i in a b c
|
||||
do
|
||||
if false
|
||||
then
|
||||
?!AMP?! echo "err"
|
||||
exit 1
|
||||
?!AMP?! fi
|
||||
foo
|
||||
?!AMP?! done
|
||||
bar
|
||||
>)
|
||||
15
t/chainlint/if-in-loop.test
Normal file
15
t/chainlint/if-in-loop.test
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(
|
||||
for i in a b c
|
||||
do
|
||||
if false
|
||||
then
|
||||
# LINT: missing "&&" on 'echo'
|
||||
echo "err"
|
||||
exit 1
|
||||
# LINT: missing "&&" on 'fi'
|
||||
fi
|
||||
foo
|
||||
# LINT: missing "&&" on 'done'
|
||||
done
|
||||
bar
|
||||
)
|
||||
19
t/chainlint/if-then-else.expect
Normal file
19
t/chainlint/if-then-else.expect
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(
|
||||
if test -n ""
|
||||
then
|
||||
?!AMP?! echo very
|
||||
echo empty
|
||||
elif test -z ""
|
||||
echo foo
|
||||
else
|
||||
echo foo &&
|
||||
cat
|
||||
?!AMP?! fi
|
||||
echo poodle
|
||||
>) &&
|
||||
(
|
||||
if test -n ""; then
|
||||
echo very &&
|
||||
?!AMP?! echo empty
|
||||
if
|
||||
>)
|
||||
28
t/chainlint/if-then-else.test
Normal file
28
t/chainlint/if-then-else.test
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
(
|
||||
# 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
|
||||
)
|
||||
4
t/chainlint/incomplete-line.expect
Normal file
4
t/chainlint/incomplete-line.expect
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
line 1 line 2 line 3 line 4 &&
|
||||
(
|
||||
line 5 line 6 line 7 line 8
|
||||
>)
|
||||
12
t/chainlint/incomplete-line.test
Normal file
12
t/chainlint/incomplete-line.test
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# LINT: stitch together all incomplete \-ending lines
|
||||
line 1 \
|
||||
line 2 \
|
||||
line 3 \
|
||||
line 4 &&
|
||||
(
|
||||
# LINT: stitch together all incomplete \-ending lines (subshell)
|
||||
line 5 \
|
||||
line 6 \
|
||||
line 7 \
|
||||
line 8
|
||||
)
|
||||
9
t/chainlint/inline-comment.expect
Normal file
9
t/chainlint/inline-comment.expect
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(
|
||||
foobar &&
|
||||
?!AMP?! barfoo
|
||||
flibble "not a # comment"
|
||||
>) &&
|
||||
|
||||
(
|
||||
cd foo &&
|
||||
> flibble "not a # comment")
|
||||
12
t/chainlint/inline-comment.test
Normal file
12
t/chainlint/inline-comment.test
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(
|
||||
# LINT: swallow inline comment (leaving command intact)
|
||||
foobar && # comment 1
|
||||
# LINT: mispositioned "&&" (correctly) swallowed with comment
|
||||
barfoo # wrong position for &&
|
||||
# LINT: "#" in string not misinterpreted as comment
|
||||
flibble "not a # comment"
|
||||
) &&
|
||||
|
||||
# LINT: "#" in string in cuddled subshell not misinterpreted as comment
|
||||
(cd foo &&
|
||||
flibble "not a # comment")
|
||||
12
t/chainlint/loop-in-if.expect
Normal file
12
t/chainlint/loop-in-if.expect
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(
|
||||
if true
|
||||
then
|
||||
while true
|
||||
do
|
||||
?!AMP?! echo "pop"
|
||||
echo "glup"
|
||||
?!AMP?! done
|
||||
foo
|
||||
?!AMP?! fi
|
||||
bar
|
||||
>)
|
||||
15
t/chainlint/loop-in-if.test
Normal file
15
t/chainlint/loop-in-if.test
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(
|
||||
if true
|
||||
then
|
||||
while true
|
||||
do
|
||||
# LINT: missing "&&" on 'echo'
|
||||
echo "pop"
|
||||
echo "glup"
|
||||
# LINT: missing "&&" on 'done'
|
||||
done
|
||||
foo
|
||||
# LINT: missing "&&" on 'fi'
|
||||
fi
|
||||
bar
|
||||
)
|
||||
18
t/chainlint/multi-line-nested-command-substitution.expect
Normal file
18
t/chainlint/multi-line-nested-command-substitution.expect
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
(
|
||||
foo &&
|
||||
x=$(
|
||||
echo bar |
|
||||
cat
|
||||
>> ) &&
|
||||
echo ok
|
||||
>) |
|
||||
sort &&
|
||||
(
|
||||
bar &&
|
||||
x=$(echo bar |
|
||||
cat
|
||||
>> ) &&
|
||||
y=$(echo baz |
|
||||
>> fip) &&
|
||||
echo fail
|
||||
>)
|
||||
18
t/chainlint/multi-line-nested-command-substitution.test
Normal file
18
t/chainlint/multi-line-nested-command-substitution.test
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
(
|
||||
foo &&
|
||||
x=$(
|
||||
echo bar |
|
||||
cat
|
||||
) &&
|
||||
echo ok
|
||||
) |
|
||||
sort &&
|
||||
(
|
||||
bar &&
|
||||
x=$(echo bar |
|
||||
cat
|
||||
) &&
|
||||
y=$(echo baz |
|
||||
fip) &&
|
||||
echo fail
|
||||
)
|
||||
15
t/chainlint/multi-line-string.expect
Normal file
15
t/chainlint/multi-line-string.expect
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(
|
||||
x="line 1 line 2 line 3" &&
|
||||
?!AMP?! y='line 1 line2'
|
||||
foobar
|
||||
>) &&
|
||||
(
|
||||
echo "there's nothing to see here" &&
|
||||
exit
|
||||
>) &&
|
||||
(
|
||||
echo "xyz" "abc def ghi" &&
|
||||
echo 'xyz' 'abc def ghi' &&
|
||||
echo 'xyz' "abc def ghi" &&
|
||||
barfoo
|
||||
>)
|
||||
27
t/chainlint/multi-line-string.test
Normal file
27
t/chainlint/multi-line-string.test
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
(
|
||||
x="line 1
|
||||
line 2
|
||||
line 3" &&
|
||||
# LINT: missing "&&" on assignment
|
||||
y='line 1
|
||||
line2'
|
||||
foobar
|
||||
) &&
|
||||
(
|
||||
# LINT: apostrophe (in a contraction) within string not misinterpreted as
|
||||
# LINT: starting multi-line single-quoted string
|
||||
echo "there's nothing to see here" &&
|
||||
exit
|
||||
) &&
|
||||
(
|
||||
echo "xyz" "abc
|
||||
def
|
||||
ghi" &&
|
||||
echo 'xyz' 'abc
|
||||
def
|
||||
ghi' &&
|
||||
echo 'xyz' "abc
|
||||
def
|
||||
ghi" &&
|
||||
barfoo
|
||||
)
|
||||
5
t/chainlint/negated-one-liner.expect
Normal file
5
t/chainlint/negated-one-liner.expect
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
! (foo && bar) &&
|
||||
! (foo && bar) >baz &&
|
||||
|
||||
?!SEMI?!! (foo; bar) &&
|
||||
?!SEMI?!! (foo; bar) >baz
|
||||
7
t/chainlint/negated-one-liner.test
Normal file
7
t/chainlint/negated-one-liner.test
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# LINT: top-level one-liner subshell
|
||||
! (foo && bar) &&
|
||||
! (foo && bar) >baz &&
|
||||
|
||||
# LINT: top-level one-liner subshell missing internal "&&"
|
||||
! (foo; bar) &&
|
||||
! (foo; bar) >baz
|
||||
19
t/chainlint/nested-cuddled-subshell.expect
Normal file
19
t/chainlint/nested-cuddled-subshell.expect
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(
|
||||
(cd foo &&
|
||||
bar
|
||||
>> ) &&
|
||||
(cd foo &&
|
||||
bar
|
||||
?!AMP?!>> )
|
||||
(
|
||||
cd foo &&
|
||||
>> bar) &&
|
||||
(
|
||||
cd foo &&
|
||||
?!AMP?!>> bar)
|
||||
(cd foo &&
|
||||
>> bar) &&
|
||||
(cd foo &&
|
||||
?!AMP?!>> bar)
|
||||
foobar
|
||||
>)
|
||||
31
t/chainlint/nested-cuddled-subshell.test
Normal file
31
t/chainlint/nested-cuddled-subshell.test
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
(
|
||||
# LINT: opening "(" cuddled with first nested subshell statement
|
||||
(cd foo &&
|
||||
bar
|
||||
) &&
|
||||
|
||||
# LINT: same but "&&" missing
|
||||
(cd foo &&
|
||||
bar
|
||||
)
|
||||
|
||||
# LINT: closing ")" cuddled with final nested subshell statement
|
||||
(
|
||||
cd foo &&
|
||||
bar) &&
|
||||
|
||||
# LINT: same but "&&" missing
|
||||
(
|
||||
cd foo &&
|
||||
bar)
|
||||
|
||||
# LINT: "(" and ")" cuddled with first and final subshell statements
|
||||
(cd foo &&
|
||||
bar) &&
|
||||
|
||||
# LINT: same but "&&" missing
|
||||
(cd foo &&
|
||||
bar)
|
||||
|
||||
foobar
|
||||
)
|
||||
7
t/chainlint/nested-here-doc.expect
Normal file
7
t/chainlint/nested-here-doc.expect
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
cat >foop &&
|
||||
|
||||
(
|
||||
cat &&
|
||||
?!AMP?! cat
|
||||
foobar
|
||||
>)
|
||||
33
t/chainlint/nested-here-doc.test
Normal file
33
t/chainlint/nested-here-doc.test
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# LINT: inner "EOF" not misintrepreted as closing ARBITRARY here-doc
|
||||
cat <<ARBITRARY >foop &&
|
||||
naddle
|
||||
fub <<EOF
|
||||
nozzle
|
||||
noodle
|
||||
EOF
|
||||
formp
|
||||
ARBITRARY
|
||||
|
||||
(
|
||||
# LINT: inner "EOF" not misintrepreted as closing INPUT_END here-doc
|
||||
cat <<-\INPUT_END &&
|
||||
fish are mice
|
||||
but geese go slow
|
||||
data <<EOF
|
||||
perl is lerp
|
||||
and nothing else
|
||||
EOF
|
||||
toink
|
||||
INPUT_END
|
||||
|
||||
# LINT: same but missing "&&"
|
||||
cat <<-\EOT
|
||||
text goes here
|
||||
data <<EOF
|
||||
data goes here
|
||||
EOF
|
||||
more test here
|
||||
EOT
|
||||
|
||||
foobar
|
||||
)
|
||||
11
t/chainlint/nested-subshell-comment.expect
Normal file
11
t/chainlint/nested-subshell-comment.expect
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(
|
||||
foo &&
|
||||
(
|
||||
bar &&
|
||||
# bottles wobble while fiddles gobble
|
||||
# minor numbers of cows (or do they?)
|
||||
baz &&
|
||||
snaff
|
||||
?!AMP?!>> )
|
||||
fuzzy
|
||||
>)
|
||||
13
t/chainlint/nested-subshell-comment.test
Normal file
13
t/chainlint/nested-subshell-comment.test
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
(
|
||||
foo &&
|
||||
(
|
||||
bar &&
|
||||
# LINT: ")" in comment in nested subshell not misinterpreted as closing ")"
|
||||
# bottles wobble while fiddles gobble
|
||||
# minor numbers of cows (or do they?)
|
||||
baz &&
|
||||
snaff
|
||||
# LINT: missing "&&" on ')'
|
||||
)
|
||||
fuzzy
|
||||
)
|
||||
12
t/chainlint/nested-subshell.expect
Normal file
12
t/chainlint/nested-subshell.expect
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(
|
||||
cd foo &&
|
||||
(
|
||||
echo a &&
|
||||
echo b
|
||||
>> ) >file &&
|
||||
cd foo &&
|
||||
(
|
||||
echo a
|
||||
echo b
|
||||
>> ) >file
|
||||
>)
|
||||
14
t/chainlint/nested-subshell.test
Normal file
14
t/chainlint/nested-subshell.test
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(
|
||||
cd foo &&
|
||||
(
|
||||
echo a &&
|
||||
echo b
|
||||
) >file &&
|
||||
|
||||
cd foo &&
|
||||
(
|
||||
# LINT: nested multi-line subshell not presently checked for missing "&&"
|
||||
echo a
|
||||
echo b
|
||||
) >file
|
||||
)
|
||||
9
t/chainlint/one-liner.expect
Normal file
9
t/chainlint/one-liner.expect
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(foo && bar) &&
|
||||
(foo && bar) |
|
||||
(foo && bar) >baz &&
|
||||
|
||||
?!SEMI?!(foo; bar) &&
|
||||
?!SEMI?!(foo; bar) |
|
||||
?!SEMI?!(foo; bar) >baz
|
||||
|
||||
(foo "bar; baz")
|
||||
12
t/chainlint/one-liner.test
Normal file
12
t/chainlint/one-liner.test
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# LINT: top-level one-liner subshell
|
||||
(foo && bar) &&
|
||||
(foo && bar) |
|
||||
(foo && bar) >baz &&
|
||||
|
||||
# LINT: top-level one-liner subshell missing internal "&&"
|
||||
(foo; bar) &&
|
||||
(foo; bar) |
|
||||
(foo; bar) >baz
|
||||
|
||||
# LINT: ";" in string not misinterpreted as broken &&-chain
|
||||
(foo "bar; baz")
|
||||
4
t/chainlint/p4-filespec.expect
Normal file
4
t/chainlint/p4-filespec.expect
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(
|
||||
p4 print -1 //depot/fiddle#42 >file &&
|
||||
foobar
|
||||
>)
|
||||
5
t/chainlint/p4-filespec.test
Normal file
5
t/chainlint/p4-filespec.test
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(
|
||||
# LINT: Perforce revspec in filespec not misinterpreted as in-line comment
|
||||
p4 print -1 //depot/fiddle#42 >file &&
|
||||
foobar
|
||||
)
|
||||
8
t/chainlint/pipe.expect
Normal file
8
t/chainlint/pipe.expect
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(
|
||||
foo |
|
||||
bar |
|
||||
baz &&
|
||||
fish |
|
||||
?!AMP?! cow
|
||||
sunder
|
||||
>)
|
||||
12
t/chainlint/pipe.test
Normal file
12
t/chainlint/pipe.test
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(
|
||||
# LINT: no "&&" needed on line ending with "|"
|
||||
foo |
|
||||
bar |
|
||||
baz &&
|
||||
|
||||
# LINT: final line of pipe sequence ('cow') lacking "&&"
|
||||
fish |
|
||||
cow
|
||||
|
||||
sunder
|
||||
)
|
||||
20
t/chainlint/semicolon.expect
Normal file
20
t/chainlint/semicolon.expect
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
(
|
||||
?!AMP?!?!SEMI?! cat foo ; echo bar
|
||||
?!SEMI?! cat foo ; echo bar
|
||||
>) &&
|
||||
(
|
||||
?!SEMI?! cat foo ; echo bar &&
|
||||
?!SEMI?! cat foo ; echo bar
|
||||
>) &&
|
||||
(
|
||||
echo "foo; bar" &&
|
||||
?!SEMI?! cat foo; echo bar
|
||||
>) &&
|
||||
(
|
||||
?!SEMI?! foo;
|
||||
>) &&
|
||||
(
|
||||
cd foo &&
|
||||
for i in a b c; do
|
||||
?!SEMI?! echo;
|
||||
> done)
|
||||
25
t/chainlint/semicolon.test
Normal file
25
t/chainlint/semicolon.test
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
(
|
||||
# LINT: missing internal "&&" and ending "&&"
|
||||
cat foo ; echo bar
|
||||
# LINT: final statement before ")" only missing internal "&&"
|
||||
cat foo ; echo bar
|
||||
) &&
|
||||
(
|
||||
# LINT: missing internal "&&"
|
||||
cat foo ; echo bar &&
|
||||
cat foo ; echo bar
|
||||
) &&
|
||||
(
|
||||
# LINT: not fooled by semicolon in string
|
||||
echo "foo; bar" &&
|
||||
cat foo; echo bar
|
||||
) &&
|
||||
(
|
||||
# LINT: unnecessary terminating semicolon
|
||||
foo;
|
||||
) &&
|
||||
(cd foo &&
|
||||
for i in a b c; do
|
||||
# LINT: unnecessary terminating semicolon
|
||||
echo;
|
||||
done)
|
||||
11
t/chainlint/subshell-here-doc.expect
Normal file
11
t/chainlint/subshell-here-doc.expect
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(
|
||||
echo wobba gorgo snoot wafta snurb &&
|
||||
?!AMP?! cat >bip
|
||||
echo >bop
|
||||
>) &&
|
||||
(
|
||||
cat >bup &&
|
||||
cat >bup2 &&
|
||||
cat >bup3 &&
|
||||
meep
|
||||
>)
|
||||
39
t/chainlint/subshell-here-doc.test
Normal file
39
t/chainlint/subshell-here-doc.test
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
(
|
||||
# LINT: stitch together incomplete \-ending lines
|
||||
# LINT: swallow here-doc to avoid false positives in content
|
||||
echo wobba \
|
||||
gorgo snoot \
|
||||
wafta snurb <<-EOF &&
|
||||
quoth the raven,
|
||||
nevermore...
|
||||
EOF
|
||||
|
||||
# LINT: missing "&&" on 'cat'
|
||||
cat <<EOF >bip
|
||||
fish fly high
|
||||
EOF
|
||||
|
||||
# LINT: swallow here-doc (EOF is last line of subshell)
|
||||
echo <<-\EOF >bop
|
||||
gomez
|
||||
morticia
|
||||
wednesday
|
||||
pugsly
|
||||
EOF
|
||||
) &&
|
||||
(
|
||||
# LINT: swallow here-doc with arbitrary tag
|
||||
cat <<-\ARBITRARY >bup &&
|
||||
glink
|
||||
FIZZ
|
||||
ARBITRARY
|
||||
cat <<-'ARBITRARY2' >bup2 &&
|
||||
glink
|
||||
FIZZ
|
||||
ARBITRARY2
|
||||
cat <<-"ARBITRARY3" >bup3 &&
|
||||
glink
|
||||
FIZZ
|
||||
ARBITRARY3
|
||||
meep
|
||||
)
|
||||
14
t/chainlint/subshell-one-liner.expect
Normal file
14
t/chainlint/subshell-one-liner.expect
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(
|
||||
(foo && bar) &&
|
||||
(foo && bar) |
|
||||
(foo && bar) >baz &&
|
||||
?!SEMI?! (foo; bar) &&
|
||||
?!SEMI?! (foo; bar) |
|
||||
?!SEMI?! (foo; bar) >baz &&
|
||||
(foo || exit 1) &&
|
||||
(foo || exit 1) |
|
||||
(foo || exit 1) >baz &&
|
||||
?!AMP?! (foo && bar)
|
||||
?!AMP?!?!SEMI?! (foo && bar; baz)
|
||||
foobar
|
||||
>)
|
||||
24
t/chainlint/subshell-one-liner.test
Normal file
24
t/chainlint/subshell-one-liner.test
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
(
|
||||
# LINT: nested one-liner subshell
|
||||
(foo && bar) &&
|
||||
(foo && bar) |
|
||||
(foo && bar) >baz &&
|
||||
|
||||
# LINT: nested one-liner subshell missing internal "&&"
|
||||
(foo; bar) &&
|
||||
(foo; bar) |
|
||||
(foo; bar) >baz &&
|
||||
|
||||
# LINT: nested one-liner subshell with "|| exit"
|
||||
(foo || exit 1) &&
|
||||
(foo || exit 1) |
|
||||
(foo || exit 1) >baz &&
|
||||
|
||||
# LINT: nested one-liner subshell lacking ending "&&"
|
||||
(foo && bar)
|
||||
|
||||
# LINT: nested one-liner subshell missing internal "&&" and lacking ending "&&"
|
||||
(foo && bar; baz)
|
||||
|
||||
foobar
|
||||
)
|
||||
10
t/chainlint/t7900-subtree.expect
Normal file
10
t/chainlint/t7900-subtree.expect
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(
|
||||
chks="sub1sub2sub3sub4" &&
|
||||
chks_sub=$(cat | sed 's,^,sub dir/,'
|
||||
>>) &&
|
||||
chkms="main-sub1main-sub2main-sub3main-sub4" &&
|
||||
chkms_sub=$(cat | sed 's,^,sub dir/,'
|
||||
>>) &&
|
||||
subfiles=$(git ls-files) &&
|
||||
check_equal "$subfiles" "$chkms$chks"
|
||||
>)
|
||||
22
t/chainlint/t7900-subtree.test
Normal file
22
t/chainlint/t7900-subtree.test
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(
|
||||
chks="sub1
|
||||
sub2
|
||||
sub3
|
||||
sub4" &&
|
||||
chks_sub=$(cat <<TXT | sed 's,^,sub dir/,'
|
||||
$chks
|
||||
TXT
|
||||
) &&
|
||||
chkms="main-sub1
|
||||
main-sub2
|
||||
main-sub3
|
||||
main-sub4" &&
|
||||
chkms_sub=$(cat <<TXT | sed 's,^,sub dir/,'
|
||||
$chkms
|
||||
TXT
|
||||
) &&
|
||||
|
||||
subfiles=$(git ls-files) &&
|
||||
check_equal "$subfiles" "$chkms
|
||||
$chks"
|
||||
)
|
||||
11
t/chainlint/while-loop.expect
Normal file
11
t/chainlint/while-loop.expect
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
(
|
||||
while true
|
||||
do
|
||||
?!AMP?! echo foo
|
||||
cat
|
||||
?!AMP?! done
|
||||
while true; do
|
||||
echo foo &&
|
||||
cat bar
|
||||
done
|
||||
>)
|
||||
19
t/chainlint/while-loop.test
Normal file
19
t/chainlint/while-loop.test
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(
|
||||
# LINT: 'while, 'do', 'done' do not need "&&"
|
||||
while true
|
||||
do
|
||||
# LINT: missing "&&" on 'echo'
|
||||
echo foo
|
||||
# LINT: last statement of while does not need "&&"
|
||||
cat <<-\EOF
|
||||
bar
|
||||
EOF
|
||||
# LINT: missing "&&" on 'done'
|
||||
done
|
||||
|
||||
# LINT: 'do' on same line as 'while'
|
||||
while true; do
|
||||
echo foo &&
|
||||
cat bar
|
||||
done
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue