Bug#1016919: lintian: bash-term-in-posix-shell false positive for `. "$(dirname "$0")/functions.sh"`
Diederik de Haas <didi.debian@cknow.org> writes:
> While inspecting lintian's output wrt (several) kernel builds I did, I
> found the following warning, which seems to be a false positive?
> I: linux-perf: bash-term-in-posix-shell '. $(dirname $0)/../lib/coresight.sh' [usr/lib/perf-core/tests/shell/coresight/asm_pure_loop.sh:8]
Yeah, I think it's a false positive in this check (check_line in
Lintian::Check::Shell::NonPosix::BashCentric):
# since this test is ugly, I have to do it by itself
# detect source (.) trying to pass args to the command it runs
# The first expression weeds out '. "foo bar"'
if (
$line !~ m{\A \s*\.\s+
(?:\"[^\"]+\"|\'[^\']+\')\s*
(?:[\&\|<;]|\d?>|\Z)}xsm
&& $line =~ /^\s*(\.\s+[^\s;\`:]+\s+([^\s;]+))/
) {
my ($dot_command, $extra) = ($1, $2);
push(@matches, $dot_command)
if length $dot_command
&& $extra !~ m{^ & | [|] | < | \d? > }x;
}
It's picking up the space in $(dirname $0) and thinking that's a space in
the . command line and therefore arguments are being passed to the sourced
file, which is a bashism. The missing logic is understanding that a $()
block is effectively a quoted string and thus should be ignored for the
purposes of this test.
--
Russ Allbery (rra@debian.org) <https://www.eyrie.org/~eagle/>
Reply to: