Skip to content

bug: backslash line continuation (\\newline) fails in some contexts #289

@chaliy

Description

@chaliy

Description

Backslash line continuation (\ at end of line) fails to parse in certain contexts, causing expected 'then' or expected 'fi' errors for valid bash scripts.

Reproduction

# Multi-line if condition (fails)
if [ -z "$A" ] || [ -z "$B" ] || \
   [ -z "$C" ]; then
    echo "missing"
fi
# parse error at line 1, column N: expected 'then'

# Multi-line command with continuation (fails)
az cognitiveservices model list --location "eastus" \
    --query "foo" \
    --output table
# parse error: expected 'fi' (when inside if block)

Source: skills.sh scripts

Found while running real-world skill scripts through bashkit parser:

  • microsoft-foundry/generate_deployment_url.sh line 67: multi-line if [ ] || \ condition
  • microsoft-foundry/query_capacity.sh lines 26-28: multi-line az command with \ continuation
  • microsoft-foundry/discover_and_rank.sh lines 20-23, 26-30: multi-line az rest calls

Cross-ref: specs/015-skills-analysis.md, tests/skills_tests.rs (parse tests pass after removing continuations)

Current behavior

The lexer has line continuation handling at lexer.rs:343, lexer.rs:489, lexer.rs:625 but it doesn't work in all token contexts. Continuation inside if conditions and inside $() command substitution appears broken.

Workaround

Join multi-line commands onto a single line (remove \ + newline). All tests pass after this transformation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions