---
title: Avoid deprecated $[expr] arithmetic expansion syntax
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Static Code Analysis (SAST) > SAST
  Rules > Avoid deprecated $[expr] arithmetic expansion syntax
---

# Avoid deprecated $[expr] arithmetic expansion syntax

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ().
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**ID:** `bash-code-quality/deprecated-bracket-arithmetic`

**Language:** Bash

**Severity:** Warning

**Category:** Code Style

## Description{% #description %}

The `$[expression]` form is an old Bash arithmetic expansion. It was never documented in POSIX, and Bash 5.2 removed support for it without a clear parse error in all cases, so scripts can fail silently on newer systems.

Use the standard `$((expression))` form instead, which is widely supported and portable.

## Non-Compliant Code Examples{% #non-compliant-code-examples %}

```bash
#!/bin/bash
echo "$[1 + 1]"
y=$[2 * 3]
```

## Compliant Code Examples{% #compliant-code-examples %}

```bash
#!/bin/bash
echo "$((1 + 1))"
x=$((a * 2))
y=$(( (3 + 4) ))
```
  Seamless integrations. Try Datadog Code SecurityDatadog Code Security 
{% icon name="icon-external-link" /%}
 