For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/static_analysis/static_analysis_rules/bash-code-quality/missing-shebang.md. A documentation index is available at /llms.txt.

Add a valid shebang as the first line of executable shell scripts

This product is not supported for your selected Datadog site. ().

Metadata

ID: bash-code-quality/missing-shebang

Language: Bash

Severity: Notice

Category: Code Style

Description

Without #! on line one, a script run directly is executed by whatever /bin/sh points to (often dash or ash), not necessarily Bash. Bash-only syntax can then fail in confusing ways or behave differently than on your interactive shell. Put a valid interpreter line first, for example #!/usr/bin/env bash or an absolute path like #!/bin/bash, matching what you actually need.

Non-Compliant Code Examples

# not a shebang
echo "if this were line 1 there would still be no interpreter path after #!"
true

Compliant Code Examples

#!/bin/bash
echo ok
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Security