]> git.ozlabs.org Git - next-scripts/blobdiff - check_fixes
check_fixes: cope with unicode quotation marks
[next-scripts] / check_fixes
index 17cfdf0c327135aeb926e7b61f9656a264d2466d..8618b08c3f8a16caf7502c1f88c97a45c4a070e7 100755 (executable)
@@ -73,10 +73,19 @@ has these problem(s):
                fi
 
                # strip matching quotes at the start and end of the subject
-               re='^(['\''"])(.*)\1$'
-               if [[ "$subject" =~ $re ]]; then
-                       subject="${BASH_REMATCH[2]}"
-               elif [[ "$subject" =~ ^[\'\"](.*)$ ]]; then
+               # the second characters in the classes are
+               # U+201C LEFT DOUBLE QUOTATION MARK
+               # U+201D RIGHT DOUBLE QUOTATION MARK
+               # U+2018 LEFT SINGLE QUOTATION MARK
+               # U+2019 RIGHT SINGLE QUOTATION MARK
+               re1=$'^[\"\u201C](.*)[\"\u201D]$'
+               re2=$'^[\'\u2018](.*)[\'\u2019]$'
+               re3=$'^[\"\'\u201C\u2018](.*)$'
+               if [[ "$subject" =~ $re1 ]]; then
+                       subject="${BASH_REMATCH[1]}"
+               elif [[ "$subject" =~ $re2 ]]; then
+                       subject="${BASH_REMATCH[1]}"
+               elif [[ "$subject" =~ $re3 ]]; then
                        subject="${BASH_REMATCH[1]}"
                        msg="${msg:+${msg}${nl}}  - Subject has leading but no trailing quotes"
                fi