From cbf20b0e01794df9d59f05b38319988f7cf74041 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 22 Jan 2019 07:39:55 +1100 Subject: [PATCH] check_fixes: cope with unicode quotation marks --- check_fixes | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/check_fixes b/check_fixes index 17cfdf0..8618b08 100755 --- a/check_fixes +++ b/check_fixes @@ -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 -- 2.39.5