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

Metadata

ID: bash-code-quality/missing-spaces-around-comparison-operator

Language: Bash

Severity: Notice

Category: Code Style

Description

In Bash [[ ... ]], comparison operators such as = and == must be separate tokens with spaces on both sides. If they are glued to operands (e.g. [[ 0=1 ]]), the shell does not treat them as operators: [[ 0=1 ]] is equivalent to [[ -n 0=1 ]] (non-empty string), not an equality test. This rule detects that glued form when it parses as a single word.

Non-Compliant Code Examples

#!/bin/bash
[[ 0=1 ]]
[[ a==b ]]

Compliant Code Examples

#!/bin/bash
[[ 0 = 1 ]]
[[ foo ]]
[[ a == b ]]
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