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

Add a special case warning for parens in for f in (a b) #1229

Open
2 of 4 tasks
koalaman opened this issue May 22, 2018 · 0 comments
Open
2 of 4 tasks

Add a special case warning for parens in for f in (a b) #1229

koalaman opened this issue May 22, 2018 · 0 comments

Comments

@koalaman
Copy link
Owner

For bugs

  • Rule Id (if any, e.g. SC1000):
  • My shellcheck version (shellcheck --version or "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:

It's somewhat common to try to put parens around for arguments:

for f in (a b c)
do echo "$f"; done

Examples:

for dir in ( cat foo.txt )
for file in ( file* )
for num in ( 0..100 )

Here's what shellcheck currently says:

Currently, this is caught with a generic "shell word starts with (" check:

for f in (a b c)
^-- SC1073: Couldn't parse this for loop. Fix to allow more checks.
         ^-- SC1036: '(' is invalid here. Did you forget to escape it?

But obviously it's not supposed to be escaped.

Here's what I wanted or expected to see:

Since the intent is known, a specific warning could be more helpful:

for f in (a b c)
^-- SC1073: Couldn't parse this for loop. Fix to allow more checks.
         ^-- SC1XXX: Remove invalid (..) around `for` arguments, or use `while read` to process command output.
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