[SCM] Git repository for devscripts branch, master, updated. v2.12.4-55-g9e10e6c
Benjamin Drung
bdrung at debian.org
Fri Oct 26 12:00:41 UTC 2012
The following commit has been merged in the master branch:
commit 0733bb676037669868f5c6703147937406701cc9
Author: Raphael Geissert <geissert at debian.org>
Date: Tue Oct 23 13:24:03 2012 -0500
checkbashisms: do not mistake bash arrays as functions
"foo=()" would trigger the function names check even though it is
an empty array being assigned to variable "foo".
Forbid the function names regex from matching if the last character in
what appears to be the function name is the equality sign. In order to
still detect a function called "=" add an extra check that requires the
sign to be proceeded by a blank or be located at the start of the line.
Signed-off-by: Benjamin Drung <bdrung at debian.org>
diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index 4bf0404..7e60f5c 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -604,7 +604,10 @@ sub init_hashes {
$LEADIN . qr'alias\s+-p' => q<alias -p>,
$LEADIN . qr'unalias\s+-a' => q<unalias -a>,
$LEADIN . qr'local\s+-[a-zA-Z]+' => q<local -opt>,
- qr'(?:^|\s)(?<func>function\s)?\s*(?:[^<>\(\)\[\]\{\};|\s]*[^<>\(\)\[\]\{\};|\s\w][^<>\(\)\[\]\{\};|\s]*)\s*(?(<func>)(?:\(\s*\))?|\(\s*\))\s*([\{|\(]|\Z)'
+ # function '=' is special-cased due to bash arrays (think of "foo=()")
+ qr'(?:^|\s)\s*=\s*\(\s*\)\s*([\{|\(]|\Z)'
+ => q<function names should only contain [a-z0-9_]>,
+ qr'(?:^|\s)(?<func>function\s)?\s*(?:[^<>\(\)\[\]\{\};|\s]*[^<>\(\)\[\]\{\};|\s\w][^<>\(\)\[\]\{\};|\s]*)(?(<func>)(?=)|(?<!=))\s*(?(<func>)(?:\(\s*\))?|\(\s*\))\s*([\{|\(]|\Z)'
=> q<function names should only contain [a-z0-9_]>,
$LEADIN . qr'(push|pop)d(\s|\Z)' => q<(push|pop)d>,
$LEADIN . qr'export\s+-[^p]' => q<export only takes -p as an option>,
--
Git repository for devscripts
More information about the devscripts-devel
mailing list