Re: [checks/scripts] checkbashsims update
On Sun, 2008-02-24 at 14:41 +0000, Adam D. Barratt wrote:
> Hi,
>
> Please find attached a patch which updates checks/scripts in line with
> recent changes to checkbashisms.
Oops. A couple of the changes were slightly broken; I've just released
devscripts 2.10.18 to fix them.
Please find attached a revised patch which fixes detection of 2>&1) (it
was allowing whitespace, pipes and semicolons to occur after the digit
but I missed closing parentheses) and the grouping on the heredoc
change.
Thanks,
Adam
--- scripts.orig 2008-02-24 14:03:47.000000000 +0000
+++ scripts 2008-02-29 07:09:27.000000000 +0000
@@ -541,8 +541,12 @@
'\$\{\#?\w+\[[0-9\*\@]+\]\}',# bash arrays, ${name[0|*|@]}
'\$\{!\w+[\@*]\}', # ${!prefix[*|@]}
'\$\{!\w+\}', # ${!name}
- '(\$\(|\`)\s*\<\s*\S.+(\)|\`)', # $(\< foo) should be $(cat foo)
+ '(\$\(|\`)\s*\<\s*\S+\s*(\)|\`)' # $(\< foo) should be $(cat foo)
'\$RANDOM\b', # $RANDOM
+ '\$(OS|MACH)TYPE\b', # $(OS|MACH)TYPE
+ '\$HOST(TYPE|NAME)\b', # $HOST(TYPE|NAME)
+ '\$DIRSTACK\b', # $DIRSTACK
+ '\$EUID\b', # $EUID should be "id -u"
);
my @bashism_regexs = (
'function \w+\(\s*\)', # function is useless
@@ -556,6 +560,7 @@
'(?:^|\s+)kill\s+-[^sl]\w*', # kill -[0-9] or -[A-Z]
'(?:^|\s+)trap\s+["\']?.*["\']?\s+.*[1-9]', # trap with signal numbers
'\&>', # cshism
+ '(<\&|>\&)\s*(-[^\s;|]|\d+[^\s;|)]|[^-\d\s;|])', # should be >word 2>&1
'\[\[(?!:)', # alternative test command
'(?:^|\s+)select\s+\w+', # 'select' is not POSIX
'\$\(\([A-Za-z]', # cnt=$((cnt + 1)) does not work in dash
@@ -564,6 +569,7 @@
'(?:^|\s+)let\s', # let ...
'(?<![\$\(])\(\(.*\)\)', # '((' should be '$(('
'(\[|test)\s+-a', # test with unary -a (should be -e)
+ '<<<', # <<< here string
);
# since this test is ugly, I have to do it by itself
@@ -610,7 +616,7 @@
# Only look for the beginning of a heredoc here, after we've
# stripped out quoted material, to avoid false positives.
- if (m/\<\<\s*[\'\"]?(\w+)[\'\"]?/) {
+ if (m/(?:^|[^<])\<\<\s*[\'\"]?(\w+)[\'\"]?/) {
$cat_string = $1;
}
}
Reply to: