Shellcheck: Feature request: recommend `for arg; do` syntax

Created on 3 Sep 2020  路  2Comments  路  Source: koalaman/shellcheck

For new checks and feature suggestions

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

#!/bin/sh
for i in "$@"; do ... done

Here's what shellcheck currently says:

Nothing

Here's what I wanted or expected to see:

This can be written more concisely and clearly as for i; do ... done

Most helpful comment

That's more clear? A for loop with an implied target? Forgive me, because I LOVE Perl, but this is not Perl. I don't think shellcheck should be in the business of playing "bash golf". And in 30+ years of coding, I have never seen this. I verified it works, but I think it's just too cute to be a desired practice. But I am not the one doing the evaluations, so good luck to you.

All 2 comments

That's more clear? A for loop with an implied target? Forgive me, because I LOVE Perl, but this is not Perl. I don't think shellcheck should be in the business of playing "bash golf". And in 30+ years of coding, I have never seen this. I verified it works, but I think it's just too cute to be a desired practice. But I am not the one doing the evaluations, so good luck to you.

OK, will admit I had while; shift loops in mind when comparing, so was slightly biased when writing OP.

On September 4, 2020 4:05:39 AM GMT+03:00, "Matthew O. Persico" notifications@github.com wrote:

That's more clear? A for loop with an implied target? Forgive me,
because I LOVE Perl, but this is not Perl. I don't think
shellcheck should be in the business of playing "bash golf". And in
30+ years of coding, I have never seen this. I verified it works,
but I think it's just too cute to be a desired practice. But I am not
the one doing the evaluations, so good luck to you.

--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
https://github.com/koalaman/shellcheck/issues/2050#issuecomment-686840458

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bbarker picture bbarker  路  3Comments

phagara picture phagara  路  4Comments

maxisme picture maxisme  路  3Comments

ghost picture ghost  路  4Comments

szepeviktor picture szepeviktor  路  4Comments