Skip to content
Ryan Parman edited this page May 23, 2024 · 3 revisions

Executable text files should have a shebang

If a text (not binary) file is marked as executable, it should begin with a shebang. This can be solved by either adding the appropriate shebang line to line 1 of the file, or by removing the executable bit.

Removing the executable bit

If the file was set to executable by mistake, you can remove the bit with:

chmod -x {FILENAME}

Adding a shebang

A shebang is a line which tells a system how to interpret the script. Most of the time, a system has built-in interpreters in the /bin or /usr/bin directory. User-installed interpreters are often installed in /usr/local/bin.

Common ones are:

If you know precisely the exact path to the exact installation you want to use:

#!/bin/bash

Using the env program search path to find it:

#!/usr/bin/env bash

If you know precisely the exact path to the exact installation you want to use:

#!/bin/python3

Using the env program search path to find it:

#!/usr/bin/env python3

Or, if you have multiple installed versions of Python (e.g., via Homebrew), you can give a more specific version:

#!/usr/bin/env python3.11
#!/usr/bin/swift
Clone this wiki locally