Package: devscripts
Version: 2.9.5
Severity: normal
Tags: patch

Hi.

The check for 'function' in checkbashisms, is not completely accurate.
The regexp for this bashism is 'function \w+\(\s*\)', but according to
the bash reference manual (page 14 in the Debian version), "If the
function reserverd word is supplied, the parentheses are optional".

So this script is a false negative, but it isn't portable:

-----------8<----------
#! /bin/sh

function foo
{
        bar
}
----------->8----------

I've attached a patch with a different regexp that reports the presence
of function, even without parentheses. I hope it doesn't reports false
positives.

Thanks.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-k7
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages devscripts depends on:
ii  debianutils                   2.14.2     Miscellaneous utilities specific t
ii  dpkg-dev                      1.13.11    package building tools for Debian
ii  libc6                         2.3.5-4    GNU C Library: Shared libraries an
ii  perl                          5.8.7-4    Larry Wall's Practical Extraction 
ii  sed                           4.1.4-2    The GNU sed stream editor

Versions of packages devscripts recommends:
ii  fakeroot                      1.4.2      Gives a fake root environment

-- no debconf information
--- checkbashisms~      2005-08-23 00:16:47.000000000 +0200
+++ checkbashisms       2005-08-23 00:31:42.000000000 +0200
@@ -102,7 +102,7 @@
            my $found = 0;
            my $match = '';
            my @bashism_regexs = (
-               'function \w+\(\s*\)',       # function is useless
+               '\s*function\s+\w+',         # function is useless
                                             # should be '.', not 'source'
                '(?:^|\s+)source\s+(?:\.\/|\/|\$)[^\s]+',
                '(\[|test|-o|-a)\s*[^\s]+\s+==\s', # should be 'b = a'

Reply via email to