From e0838edb19f2426c97dfd6f15a05010b9f282abf Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Thu, 3 Sep 2015 18:54:26 +0300 Subject: [PATCH] Add compatibility section explaining differences in Bash 3.1 and Bash 3.2 behavior --- SC2076.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/SC2076.md b/SC2076.md index 6c8c7d7..9b0aa21 100644 --- a/SC2076.md +++ b/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"* ]]`. \ No newline at end of file +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 \ No newline at end of file