Skip to content

[BUG] Range expressions generate ambiguous $((seq pattern (SC1102) #1056

@lens0021

Description

@lens0021

Describe the bug

Range expressions (a..b, a..=b) generate a printf call containing "$((seq ...", which ShellCheck flags as error SC1102. The $(( token is ambiguous: shells and ShellCheck parse it as the start of an arithmetic expansion $((...)) rather than a command substitution $( wrapping a grouped command (seq ...).

Amber version: dd1b7dc

To Reproduce

main {
    echo(0..10)
}
echo '
main {
    echo(0..10)
}
' | cargo run -- build - - | shellcheck --format gcc -

Generated Bash:

printf '%s\n' "$((seq -f "%.0f" -- 0 9 || seq -- 0 9) | paste -sd " " -)"
#              ^^^
#              parsed as $(( arithmetic )) by ShellCheck and POSIX shells

ShellCheck output:

-:4:16: error: Shells disambiguate $(( differently or not at all. For $(command substitution), add space after $( . For $((arithmetics)), fix parsing errors. [SC1102]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions