Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive when closing a named coproc's fd #3130

Open
3 of 4 tasks
silicon-salamander opened this issue Jan 24, 2025 · 0 comments
Open
3 of 4 tasks

False positive when closing a named coproc's fd #3130

silicon-salamander opened this issue Jan 24, 2025 · 0 comments

Comments

@silicon-salamander
Copy link

silicon-salamander commented Jan 24, 2025

For bugs

  • Rule Id (if any, e.g. SC1000): SC2093, SC1083, SC1083
  • My shellcheck version (shellcheck --version or 'online'): online
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

For new checks and feature suggestions

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

#!/bin/bash

coproc tr { tr a b; }
echo aaa >&"${tr[1]}"

exec {tr[1]}>&- # errors here

cat <&"${tr[0]}"

Here's what shellcheck currently says:

Line 6	SC2093: Remove "exec " if script should continue after this command.
Line 6	SC1083: This { is literal. Check expression (missing ;/\n?) or quote it.
Line 6	SC1083: This } is literal. Check expression (missing ;/\n?) or quote it.

Here's what I wanted or expected to see:

Expected no errors. exec {tr[1]}>&- works correctly on bash version 5.2.37.
According to this SE answer this syntax is not valid in bash versions prior to 4.3.
https://unix.stackexchange.com/a/86372

Also relevant bash change log entry.
https://git.savannah.gnu.org/cgit/bash.git/tree/CWRU/changelog?id=30a978b7d808c067219c95be88c4979b6a7aa251#n3427

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant