Skip to content

Files

Latest commit

 

History

History
37 lines (23 loc) · 920 Bytes

SC2239.md

File metadata and controls

37 lines (23 loc) · 920 Bytes

Pattern: Missing absolute path to the interpreter

Issue: -

Description

The script's interpreter, as specified in the shebang, does not start with a /.

The interpreter should always be specified by absolute path to ensure that the script can be executed from any directory. When it's not, it's generally a typo like in the problematic example.

If you don't know where the interpreter is and you hoped to use #! bash, this is not an option. Use /usr/bin/env instead:

#!/usr/bin/env bash
echo "Hello World"

While not required by POSIX, env can essentially always be found in /usr/bin and will search the PATH for the specified executable.

Example of incorrect code:

#!bin/sh
echo "Hello World"

Example of correct code:

#!/bin/sh
echo "Hello World"

Further Reading