[devscripts] 01/01: checkbashisms: Sort hash keys to provide consistently ordered output.
James McCoy
jamessan at debian.org
Thu Sep 19 22:52:09 UTC 2013
This is an automated email from the git hooks/post-receive script.
jamessan pushed a commit to branch master
in repository devscripts.
commit ec6bd2583ed2a547cd3164a2d863030f8c3c8df5
Author: James McCoy <jamessan at debian.org>
Date: Thu Sep 19 18:51:00 2013 -0400
checkbashisms: Sort hash keys to provide consistently ordered output.
Signed-off-by: James McCoy <jamessan at debian.org>
---
debian/changelog | 3 +++
scripts/checkbashisms.pl | 15 +++++++++++----
test/bashisms/functions.sh.out | 16 ++++++++--------
3 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 5f6acee..89c662c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,9 @@ devscripts (2.13.4) UNRELEASED; urgency=low
* Make curl return a proper exit code for HTTP errors. (Closes: #720508)
* mk-build-deps: Define the deb's version when parsing a debian/control
file. (Closes: #721939)
+ * checkbashisms: Sort the keys of the bashisms hashes to provide
+ consistently ordered output. This avoids false positive failures in the
+ test suite.
[ Charles Pigott ]
* Fix POD issues. (LP: #1226318, Closes: #719828)
diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index 44369d4..9e53808 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -83,6 +83,10 @@ my (%bashisms, %string_bashisms, %singlequote_bashisms);
my $LEADIN = qr'(?:(?:^|[`&;(|{])\s*|(?:if|then|do|while|shell)\s+)';
init_hashes;
+my @bashisms_keys = sort keys %bashisms;
+my @string_bashisms_keys = sort keys %string_bashisms;
+my @singlequote_bashisms_keys = sort keys %singlequote_bashisms;
+
foreach my $filename (@ARGV) {
my $check_lines_count = -1;
@@ -372,7 +376,8 @@ foreach my $filename (@ARGV) {
$line =~ s/(^|[^\\\'\"])\"\'\"/$1/g;
$line =~ s/(^|[^\\\'\"])\'\"\'/$1/g;
- while (my ($re,$expl) = each %singlequote_bashisms) {
+ foreach my $re (@singlequote_bashisms_keys) {
+ my $expl = $singlequote_bashisms{$re};
if ($line =~ m/($re)/) {
$found = 1;
$match = $1;
@@ -417,7 +422,8 @@ foreach my $filename (@ARGV) {
}
}
- while (my ($re,$expl) = each %string_bashisms) {
+ foreach my $re (@string_bashisms_keys) {
+ my $expl = $string_bashisms{$re};
if ($line =~ m/($re)/) {
$found = 1;
$match = $1;
@@ -430,8 +436,9 @@ foreach my $filename (@ARGV) {
# double-quoted strings, so now remove those strings as well.
$line =~ s/(^|[^\\\'](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g;
$cat_line =~ s/(^|[^<\\\'-](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g;
- while (my ($re,$expl) = each %bashisms) {
- if ($line =~ m/($re)/) {
+ foreach my $re (@bashisms_keys) {
+ my $expl = $bashisms{$re};
+ if ($line =~ m/($re)/) {
$found = 1;
$match = $1;
$explanation = $expl;
diff --git a/test/bashisms/functions.sh.out b/test/bashisms/functions.sh.out
index f11bf39..61a4c4d 100644
--- a/test/bashisms/functions.sh.out
+++ b/test/bashisms/functions.sh.out
@@ -8,25 +8,25 @@ possible bashism in bashisms/functions.sh line 25 (should be >word 2>&1):
} &>/dev/null # BASHISM
possible bashism in bashisms/functions.sh line 27 (function names should only contain [a-z0-9_]):
,() { # BASHISM
-possible bashism in bashisms/functions.sh line 31 ('function' is useless):
-function foo:bar:BASHISM { # BASHISMS
possible bashism in bashisms/functions.sh line 31 (function names should only contain [a-z0-9_]):
function foo:bar:BASHISM { # BASHISMS
-possible bashism in bashisms/functions.sh line 35 ('function' is useless):
-function foo-bar-BASHISM() { # BASHISMS
+possible bashism in bashisms/functions.sh line 31 ('function' is useless):
+function foo:bar:BASHISM { # BASHISMS
possible bashism in bashisms/functions.sh line 35 (function names should only contain [a-z0-9_]):
function foo-bar-BASHISM() { # BASHISMS
+possible bashism in bashisms/functions.sh line 35 ('function' is useless):
+function foo-bar-BASHISM() { # BASHISMS
possible bashism in bashisms/functions.sh line 39 (function names should only contain [a-z0-9_]):
foo-bar-BASHISM ( ) {
possible bashism in bashisms/functions.sh line 47 ('function' is useless):
function _ { #BASHISM
possible bashism in bashisms/functions.sh line 51 (function names should only contain [a-z0-9_]):
=() { #BASHISM
-possible bashism in bashisms/functions.sh line 55 ('function' is useless):
-function BASHISM=() { #BASHISMS
possible bashism in bashisms/functions.sh line 55 (function names should only contain [a-z0-9_]):
function BASHISM=() { #BASHISMS
-possible bashism in bashisms/functions.sh line 59 ('function' is useless):
-function BASHISM= { #BASHISMS
+possible bashism in bashisms/functions.sh line 55 ('function' is useless):
+function BASHISM=() { #BASHISMS
possible bashism in bashisms/functions.sh line 59 (function names should only contain [a-z0-9_]):
function BASHISM= { #BASHISMS
+possible bashism in bashisms/functions.sh line 59 ('function' is useless):
+function BASHISM= { #BASHISMS
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git
More information about the devscripts-devel
mailing list