[devscripts] 02/02: checkbashisms: Included elif and negation in $LEADIN
James McCoy
jamessan at debian.org
Sat Dec 19 15:02:19 UTC 2015
This is an automated email from the git hooks/post-receive script.
jamessan pushed a commit to branch master
in repository devscripts.
commit 398fccc9ab35b9ca92d14511d2b2094e63f1df6f
Author: James McCoy <jamessan at debian.org>
Date: Sat Dec 19 09:46:22 2015 -0500
checkbashisms: Included elif and negation in $LEADIN
Closes: #808271
Signed-off-by: James McCoy <jamessan at debian.org>
---
debian/changelog | 3 +++
scripts/checkbashisms.pl | 2 +-
test/bashisms/808271.sh | 9 +++++++++
test/bashisms/808271.sh.out | 4 ++++
test/test_checkbashisms | 4 ++++
5 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index ea84809..32c085a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -120,6 +120,9 @@ devscripts (2.15.10) UNRELEASED; urgency=medium
* bts:
+ Fix creation of cache dir when $XDG_CACHE_HOME doesn't exist yet.
(Closes: #808394)
+ * checkbashisms:
+ + Improve detection of bashisms when a ! is included after an
+ if/while/elif conditional. (Closes: #808271)
[ Daniel Kahn Gillmor ]
* debuild:
diff --git a/scripts/checkbashisms.pl b/scripts/checkbashisms.pl
index 045328c..cd7919c 100755
--- a/scripts/checkbashisms.pl
+++ b/scripts/checkbashisms.pl
@@ -81,7 +81,7 @@ my $status = 0;
my $makefile = 0;
my (%bashisms, %string_bashisms, %singlequote_bashisms);
-my $LEADIN = qr'(?:(?:^|[`&;(|{])\s*|(?:if|then|do|while|shell)\s+)';
+my $LEADIN = qr'(?:(?:^|[`&;(|{])\s*|(?:(?:if|elif|while)(?:\s+!)?|then|do|shell)\s+)';
init_hashes;
my @bashisms_keys = sort keys %bashisms;
diff --git a/test/bashisms/808271.sh b/test/bashisms/808271.sh
new file mode 100644
index 0000000..0789d7e
--- /dev/null
+++ b/test/bashisms/808271.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if type which; then
+ echo "use which"
+fi
+
+if ! type which; then
+ echo "well, idk"
+fi
diff --git a/test/bashisms/808271.sh.out b/test/bashisms/808271.sh.out
new file mode 100644
index 0000000..6cb8156
--- /dev/null
+++ b/test/bashisms/808271.sh.out
@@ -0,0 +1,4 @@
+possible bashism in bashisms/808271.sh line 3 (type):
+if type which; then
+possible bashism in bashisms/808271.sh line 7 (type):
+if ! type which; then
diff --git a/test/test_checkbashisms b/test/test_checkbashisms
index a2d197d..b352be6 100755
--- a/test/test_checkbashisms
+++ b/test/test_checkbashisms
@@ -43,6 +43,10 @@ test_535368() {
clean "-f bashisms/535368.mk"
}
+test_808271() {
+ found "bashisms/808271.sh" "$(cat bashisms/808271.sh.out)"
+}
+
test_arith() {
found "bashisms/arith.sh" "$(cat bashisms/arith.sh.out)"
}
--
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