mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Add compatibility section explaining differences in Bash 3.1 and Bash 3.2 behavior
10
SC2076.md
10
SC2076.md
@@ -16,4 +16,12 @@ This also means that the problematic code tries to match literal carets and plus
|
||||
|
||||
### Exceptions:
|
||||
|
||||
If you do want to match literally just to do a plain substring search, e.g. `[[ $foo =~ "bar" ]]`, you could ignore this message, but consider using a more canonical glob match instead: `[[ $foo = *"bar"* ]]`.
|
||||
If you do want to match literally just to do a plain substring search, e.g. `[[ $foo =~ "bar" ]]`, you could ignore this message, but consider using a more canonical glob match instead: `[[ $foo = *"bar"* ]]`.
|
||||
|
||||
### Compatibility:
|
||||
|
||||
* In Bash 3.2 and newer with shopt `compat31` *disabled (the default)*, quoted patterns are literal whereas unquoted patterns are parsed for regex metacharacters.
|
||||
* In Bash 3.2 and newer with shopt `compat31` *enabled*, quoted and unquoted patterns match identically.
|
||||
* In Bash 3.1 quoted and unquoted patterns match identically.
|
||||
|
||||
See http://stackoverflow.com/questions/218156/bash-regex-with-quotes
|
Reference in New Issue
Block a user