Add compatibility section explaining differences in Bash 3.1 and Bash 3.2 behavior

Lassi Kortela
2015-09-03 18:54:26 +03:00
parent 3f3bbb0966
commit e0838edb19

@@ -17,3 +17,11 @@ This also means that the problematic code tries to match literal carets and plus
### Exceptions: ### 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