koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.45k stars 1.78k forks source link

SC1089: bash: coproc "NAME" { ...; } - quoted NAME kills parsing #3048

Closed iam-TJ closed 2 months ago

iam-TJ commented 2 months ago

For bugs

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/usr/bin/env bash
coproc COPROC_NAME1 { echo "/directory"  ; }
echo "${COPROC_NAME1[0]}"
coproc "COPROC_NAME2" { echo "/directory"  ; }
cname="COPROC_NAME_$$"
coproc "$cname" { echo "/directory"  ; }

Here's what shellcheck currently says:

Line 4  SC1083: This { is literal. Check expression (missing ;/\n?) or quote it.
Line 4  SC1089: Parsing stopped here. Is this keyword correctly matched up?

Here's what I wanted or expected to see:

Allow quoted NAME

koalaman commented 2 months ago

Wow, what an embarrassing deficiency. This was caused by oversimplified code from the early days (Jan 2015) that just hadn't been revisited since. You can now use arbitrary names. Thanks!