Skip to content

Files

Latest commit

 

History

History
30 lines (18 loc) · 783 Bytes

SC2096.md

File metadata and controls

30 lines (18 loc) · 783 Bytes

Pattern: Use of shebang with more than one parameter

Issue: -

Description

Most operating systems, including POSIX, Linux and FreeBSD, allow only a single parameter in the shebang. The example is equivalent to calling env 'bash -x' instead of env 'bash' '-x', and it will therefore fail.

The shebang should be rewritten to use at most one parameter. Shell options can instead be set in the body of the script.

Example of incorrect code:

#!/usr/bin/env bash -x

Example of correct code:

#!/usr/bin/env bash
set -x

Exceptions

macOS X currently allows multiple words in the shebang. Scripts running on OSX exclusively can ignore this warning.

Further Reading