FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

SC2201 · koalaman/shellcheck Wiki · GitHub

SC2201 · koalaman/shellcheck Wiki · GitHub
Skip to content

Navigation Menu

koalaman edited this page Dec 31, 2016 · 2 revisions

Brace expansion doesn't happen in [[ ]]. Use a loop.

Problematic code:

[[ "$file" = index.{htm,html,php} ]] && echo "This is the main file"

Correct code:

for main in index.{htm,html,php}
do
  [[ "$file" = "$main" ]] && echo "This is the main file"
done

Rationale:

Brace expansions doesn't happen in [[ ]]. They will just be interpreted literally.

Instead, use a for loop to iterate over values, and apply your condition to each.

Exceptions:

None.

Wiki pages Pages 545

Clone this wiki locally

Footer

© 2026 GitHub, Inc.

Back | FazBrowse Home | New Git URL