Author: djpig
Date: 2005-10-13 14:49:29 +0200 (Thu, 13 Oct 2005)
New Revision: 504

Modified:
   trunk/checks/scripts
   trunk/checks/scripts.desc
   trunk/debian/changelog
   trunk/testset/tags.libbaz
   trunk/testset/tags.maintainer-scripts
Log:
Better reflect the current discussions wether some of the
XSI:sms should be allowed in shell scripts by moving some of
them to a separate check possible-non-posix-code-in-maintainer-script.
Not doing that for kill -NAME as reuqested since -s NAME is available
and should be perfectly portable. (Closes: #323053)


Modified: trunk/checks/scripts
===================================================================
--- trunk/checks/scripts        2005-10-13 12:22:38 UTC (rev 503)
+++ trunk/checks/scripts        2005-10-13 12:49:29 UTC (rev 504)
@@ -443,6 +443,7 @@
            # check for things
            if ($cat_string eq "" and $checkbashisms and 
!$within_another_shell) {
                my $found = 0;
+               my $found_strict = 0;
                my $match = '';
                my @bashism_regexs = (
                  'function \w+\(\s*\)',       # function is useless
@@ -457,13 +458,16 @@
                  '(?:^|\s+)\w+\[\d+\]=',      # bash arrays, H[0]
                  '[EMAIL PROTECTED]',# bash arrays, ${name[0|*|@]}
                  '(?:^|\s+)read\s*(?:;|$)', # read without variable
-                 '((?:test|\[)\s+.+\s-[ao])\s',# test/[ -a/-o binary operators
+
                  '(?:^|\s+)kill\s+-[^sl]\w*',   # kill -[0-9] or -[A-Z]
                  '(?:^|\s+)trap\s+["\']?.*["\']?\s+.*[1-9]', # trap with 
signal numbers
-                 '(?:^\s*)local\s',        # local scoping of variables
                  '\&>',                     # cshism
                  '\[\[(?!:)',                    # alternative test command
                );
+               my @strict_posix_regexs = (
+                 '((?:test|\[)\s+.+\s-[ao])\s',# test/[ -a/-o binary operators
+                 '(?:^\s*)local\s',        # local scoping of variables
+                                          );
 
                for my $re (@bashism_regexs) {
                    if (m/($re)/) {
@@ -472,6 +476,17 @@
                        last;
                    }
                }
+               unless ($found) {
+                   for my $re (@strict_posix_regexs) {
+                       if (m/($re)/) {
+                           $found = 1;
+                           $found_strict = 1;
+                           $match = $1;
+                           last;
+                       }
+                   }
+               }
+
                # since this test is ugly, I have to do it by itself
                # detect source (.) trying to pass args to the command it runs
                if (not $found and m/^\s*(\.\s+[^\s]+\s+([^\s]+))/) {
@@ -483,7 +498,9 @@
                        $match = $1;
                    }
                }
-               unless ($found == 0) {
+               if ($found && $found_strict) {
+                   tag "possible-non-posix-code-in-maintainer-script", 
"$file:$. \'$match\'";
+               } elsif ($found) {
                    tag "possible-bashism-in-maintainer-script", "$file:$. 
\'$match\'";
                }
            }

Modified: trunk/checks/scripts.desc
===================================================================
--- trunk/checks/scripts.desc   2005-10-13 12:22:38 UTC (rev 503)
+++ trunk/checks/scripts.desc   2005-10-13 12:49:29 UTC (rev 504)
@@ -610,6 +610,20 @@
   '. command args', passing arguments to commands via 'source' is not supported
   '{foo,bar}' instead of 'foo bar'
 
+Tag: possible-non-posix-code-in-maintainer-script
+Type: info
+Ref: policy 10.4
+Info: This script is marked as running under <tt>/bin/sh</tt>, but it seems
+ to use a shell feature that is not defined in the POSIX standard. The
+ feature is so common in current shells that this isn't currently
+ considered an release critical bug and there are discussion wether
+ policy should be amended to specifically allow the use of the feature.
+ .
+ Examples:
+  '-a' and '-o' as operators of 'test'. You can use shell conditionals
+  (&& and ||) instead.
+  'local' scoping of variables.
+
 Tag: suidregister-used-in-maintainer-script
 Type: error
 Info: This script calls suidregister which is no longer needed, a new

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2005-10-13 12:22:38 UTC (rev 503)
+++ trunk/debian/changelog      2005-10-13 12:49:29 UTC (rev 504)
@@ -24,6 +24,11 @@
       Noted by Matthias Klose (Closes: #326643)
     + [FL] Only match 'local' at the beginning of a line. The check is too
       ambigious otherwise. Reported by Marc Haber (Closes: #330548)
+    + [FL] Better reflect the current discussions wether some of the
+      XSI:sms should be allowed in shell scripts by moving some of
+      them to a separate check possible-non-posix-code-in-maintainer-script.
+      Not doing that for kill -NAME as reuqested since -s NAME is available
+      and should be perfectly portable. (Closes: #323053)
   * checks/shared-libs:
     + [HE] Apply patch from Bastian Blank to check for executable stacks in
       binaries. New checks are called shlib-without-PT_GNU_STACK-section,

Modified: trunk/testset/tags.libbaz
===================================================================
--- trunk/testset/tags.libbaz   2005-10-13 12:22:38 UTC (rev 503)
+++ trunk/testset/tags.libbaz   2005-10-13 12:49:29 UTC (rev 504)
@@ -8,14 +8,14 @@
 E: libbaz1: shlib-with-non-pic-code usr/lib/libbaz1.so.1.0.3b
 E: libbaz1: unstripped-binary-or-object ./usr/lib/libbaz1.so.1.0.3b
 E: libbaz1: unstripped-binary-or-object ./usr/lib/libfoo2.so.1.0.3b
+I: libbaz1: possible-non-posix-code-in-maintainer-script postinst:6 '[ -d 
/usr/doc -a ! -e /usr/doc/$PKG -a '
+I: libbaz1: possible-non-posix-code-in-maintainer-script prerm:5 '[ \( "$1" = 
"upgrade" -o "$1" = "remove" \) -a '
 W: libbaz source: ancient-standards-version 3.2.1
 W: libbaz source: changelog-should-mention-nmu
 W: libbaz source: package-uses-deprecated-debhelper-compat-version 1
 W: libbaz source: source-nmu-has-incorrect-version-number 1
 W: libbaz1: missing-depends-line
 W: libbaz1: package-name-doesnt-match-sonames libbaz2-1.0
-W: libbaz1: possible-bashism-in-maintainer-script postinst:6 '[ -d /usr/doc -a 
! -e /usr/doc/$PKG -a '
-W: libbaz1: possible-bashism-in-maintainer-script prerm:5 '[ \( "$1" = 
"upgrade" -o "$1" = "remove" \) -a '
 W: libbaz1: postinst-should-not-set-usr-doc-link
 W: libbaz1: zero-byte-file-in-doc-directory usr/share/doc/README.Debian
 W: libbaz2: package-name-doesnt-match-sonames libbaz2-1.0

Modified: trunk/testset/tags.maintainer-scripts
===================================================================
--- trunk/testset/tags.maintainer-scripts       2005-10-13 12:22:38 UTC (rev 
503)
+++ trunk/testset/tags.maintainer-scripts       2005-10-13 12:49:29 UTC (rev 
504)
@@ -9,6 +9,8 @@
 E: maintainer-scripts: maintainer-shell-script-fails-syntax-check prerm
 E: maintainer-scripts: no-copyright-file
 E: maintainer-scripts: wrong-debian-qa-group-name QA group <[EMAIL PROTECTED]>
+I: maintainer-scripts: possible-non-posix-code-in-maintainer-script postinst:4 
'[ -d /usr/doc -a ! -e /usr/doc/maintainer-scripts -a '
+I: maintainer-scripts: possible-non-posix-code-in-maintainer-script prerm:25 ' 
  local '
 W: maintainer-scripts source: ancient-standards-version 3.1.1
 W: maintainer-scripts source: changelog-should-mention-qa
 W: maintainer-scripts source: qa-upload-has-incorrect-version-number 7-0.1
@@ -22,10 +24,8 @@
 W: maintainer-scripts: possible-bashism-in-maintainer-script postinst:20 
'H[0]='
 W: maintainer-scripts: possible-bashism-in-maintainer-script postinst:21 
'${H[0]}'
 W: maintainer-scripts: possible-bashism-in-maintainer-script postinst:23 
'[EMAIL PROTECTED]'
-W: maintainer-scripts: possible-bashism-in-maintainer-script postinst:4 '[ -d 
/usr/doc -a ! -e /usr/doc/maintainer-scripts -a '
 W: maintainer-scripts: possible-bashism-in-maintainer-script prerm:19 '[ "$2" 
== '
 W: maintainer-scripts: possible-bashism-in-maintainer-script prerm:23 
'function foo( )'
-W: maintainer-scripts: possible-bashism-in-maintainer-script prerm:25 '   
local '
 W: maintainer-scripts: possible-bashism-in-maintainer-script prerm:26 '&>'
 W: maintainer-scripts: possible-bashism-in-maintainer-script prerm:29 'source 
$FOO'
 W: maintainer-scripts: possible-bashism-in-maintainer-script prerm:31 'trap 
"echo hi" EXIT HUP 3'


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to