koalaman / shellcheck

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

Encourage dot (`.`) over `source` #208

Closed mcandre closed 10 years ago

mcandre commented 10 years ago

Though checkbashisms does not report this, I believe source is a bashism; POSIX sh (and even modern descendants like ash/dash) only recognizes the dot (.) command.

Could shellcheck get an optional rule for this, disabled by default? Something like:

In hello.sh line 1:
  source world.sh
  ^-- Replace source with dot (.) for POSIX compatibility
mcandre commented 10 years ago

Note: Except for csh/tcsh, which are non-POSIX compliant. csh and tcsh only recognize source, not dot (.).

koalaman commented 10 years ago

When specifying #!/bin/sh or -s sh, you get

source foo
^-- SC2039: #!/bin/sh was specified, but 'source' in place of '.' is not standard.