koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.2k stars 1.77k forks source link

FEAT: check if using dot command in posix shell without a slash in the filename #1081

Open jumanjiman opened 6 years ago

jumanjiman commented 6 years ago

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/bin/sh
. path_without_a_slash

Here's what shellcheck currently says:

SC1091: Not following: path_without_a_slash was not specified as input (see shellcheck -x).

Here's what I wanted or expected to see:

SC1091: Not following: path_without_a_slash was not specified as input (see shellcheck -x). SCxxxx: In POSIX sh, dot command follows PATH if filename lacks a slash

POSIX specification

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#dot

pabs3 commented 6 years ago

Please note that this syntax works in bash, because it adds the current directory to the path used for the dot command.