[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#699410: false positive for shell-script-fails-syntax-check (bash -O extglob)



Package: lintian
Version: 2.5.10.3
Severity: minor

In an exceptionally stupid in-house package, I ran across a false
positive for shell-script-fails-syntax-check.  Distilled, it is

    $ cat tmp.bash
    #!/bin/bash
    shopt -s extglob
    ls -ld /home/!(prisoners)

    $ bash -n tmp.bash
    tmp.bash: line 3: syntax error near unexpected token `('
    tmp.bash: line 3: `ls -ld /home/!(prisoners)'

    $ bash -O extglob -n tmp.bash

    $ bash tmp.bash
    drwxr-xr-x 1 twb twb 6538 Jan 27 00:00 /home/twb

This happens because -n prevents bash from switching into extglob mode
before parsing the third line.  Manually telling bash to be in extglob
at the start of the file shows it has no syntax errors.

A pathological script could turn extglob/nullglob/&c on and off
halfway through, so I see no way to handle this other than to
downgrade the certainty from "certain", at least for bash scripts.

-- System Information:
Debian Release: 7.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.7-trunk-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_AU.utf8, LC_CTYPE=en_AU.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages lintian depends on:
ii  binutils                       2.22-7.1
ii  bzip2                          1.0.6-4
ii  diffstat                       1.55-3
ii  file                           5.11-2
ii  gettext                        0.18.1.1-9
ii  hardening-includes             2.2
ii  intltool-debian                0.35.0+20060710.1
ii  libapt-pkg-perl                0.1.26+b1
ii  libarchive-zip-perl            1.30-6
ii  libc-bin                       2.13-37
ii  libclass-accessor-perl         0.34-1
ii  libclone-perl                  0.31-1+b2
ii  libdpkg-perl                   1.16.9
ii  libemail-valid-perl            0.190-1
ii  libipc-run-perl                0.92-1
ii  libparse-debianchangelog-perl  1.2.0-1
ii  libtimedate-perl               1.2000-1
ii  liburi-perl                    1.60-1
ii  locales                        2.13-37
ii  man-db                         2.6.2-1
ii  patchutils                     0.3.2-1.1
ii  perl [libdigest-sha-perl]      5.14.2-16

lintian recommends no packages.

Versions of packages lintian suggests:
pn  binutils-multiarch     <none>
ii  dpkg-dev               1.16.9
ii  libhtml-parser-perl    3.69-2
pn  libperlio-gzip-perl    <none>
pn  libtext-template-perl  <none>
ii  man-db                 2.6.2-1
ii  xz-utils [lzma]        5.1.1alpha+20120614-2

-- no debconf information


Reply to: