Description
The bashkit parser does not reject several invalid syntax constructs that real bash rejects as parse errors.
Scope
${%} — invalid braced var sub not rejected
{ls; } — { without space not rejected (should be parse error)
for i.j in ... — invalid for-loop variable name not rejected
export FOO-BAR=foo — invalid variable name in export not rejected
local FOO-BAR=foo — invalid variable name in local not rejected
echo a(b) — misplaced parentheses not rejected
- Incomplete command sub
$(x — not detected
- Incomplete backticks — not detected
[[ || true ]] — empty clause in [[ not rejected
- Unterminated single and double quotes not detected
- Empty
while/for/if/else/function bodies not rejected (bash requires at least : or a command)
Repro
# bashkit: no error (wrong)
# bash: syntax error
for i.j in a b c; do echo hi; done
# bashkit: outputs the text (wrong)
# bash: syntax error, exit 2
echo 'unterminated
# bashkit: allows empty body (wrong)
# bash: syntax error near unexpected token 'done'
while false; do
done
Test coverage
- 11 skipped tests in
crates/bashkit/tests/spec_cases/bash/parse-errors.test.sh
- 5 skipped tests in
crates/bashkit/tests/spec_cases/bash/empty-bodies.test.sh
All added in PR #351.
Oils reference: https://github.com/oilshell/oil/blob/master/spec/parse-errors.test.sh
Description
The bashkit parser does not reject several invalid syntax constructs that real bash rejects as parse errors.
Scope
${%}— invalid braced var sub not rejected{ls; }—{without space not rejected (should be parse error)for i.j in ...— invalid for-loop variable name not rejectedexport FOO-BAR=foo— invalid variable name in export not rejectedlocal FOO-BAR=foo— invalid variable name in local not rejectedecho a(b)— misplaced parentheses not rejected$(x— not detected[[ || true ]]— empty clause in[[not rejectedwhile/for/if/else/function bodies not rejected (bash requires at least:or a command)Repro
Test coverage
crates/bashkit/tests/spec_cases/bash/parse-errors.test.shcrates/bashkit/tests/spec_cases/bash/empty-bodies.test.shAll added in PR #351.
Oils reference: https://github.com/oilshell/oil/blob/master/spec/parse-errors.test.sh