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

Bug#478192: maintainer-shell-script-fails-syntax-check should be more consistent



Package: lintian 
Version: 1.23.46

checks/scripts:
>     my $checkbashisms;
>     if ($shellscript) {
>         $checkbashisms = $base eq "sh" ? 1 : 0;
>         if ($base eq 'sh' or $base eq 'bash') {
>             if (check_script_syntax("/bin/$base", $filename)) {
>                 tag("maintainer-shell-script-fails-syntax-check", $file);
>             }
>         }
>     }

IMHO for the sake of consistency lintian should use the same interpreter when 
checking for sh scripts (i.e. use /bin/bash instead of /bin/sh which can be 
linked to <insert your favourite policy-compliant sh interpreter here>).

The following test case demonstrates a situation where lintian will throw 
different results:

> $ cat /tmp/bc
> #!/bin/sh
> if [[ "$command" == @(help|h|\?) ]]; then
>    COMPREPLY=( $( compgen -W "$commands" -- $cur ) ) 
> else 
>    _filedir
> fi

> $ bash -n /tmp/bc
> /tmp/bc: line 2: syntax error in conditional expression: unexpected token
> `(' /tmp/bc: line 2: syntax error near `@(h'
> /tmp/bc: line 2: `                        if [[ "$command" == @(help|h|\?)
> ]]; then' 

> $ dash -n /tmp/bc 
> /tmp/bc: 2: Syntax error: "(" unexpected (expecting "then")

> $ posh -n /tmp/bc
> /tmp/bc:2: syntax error: `(' unexpected

> $ ksh -n /tmp/bc

> $ mksh -n /tmp/bc

> $ pdksh -n /tmp/bc
> /tmp/bc[3]: syntax error: `(' unexpected

> $ zsh -n /tmp/bc

So, if a .deb ships a #!/bin/sh maintainer script with the above code snippet 
and lintian is run on that .deb, the 
maintainer-shell-script-fails-syntax-check tag will only be triggered 
when /bin/sh links to bash, dash, posh, or pdksh, but won't when linking to 
ksh, mksh, or zsh.

Cheers,
-- 
Atomo64 - Raphael

Please avoid sending me Word, PowerPoint or Excel attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: