---
title: Do not mask command exit status in export assignments
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Static Code Analysis (SAST) > SAST
  Rules > Do not mask command exit status in export assignments
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Do not mask command exit status in export assignments

{% 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). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Metadata{% #metadata %}

**ID:** `bash-code-quality/dont-mask-return-values`

**Language:** Bash

**Severity:** Warning

**Category:** Best Practices

## Description{% #description %}

Combining export with command substitution on one line hides the exit status of the command. The assignment runs a command, but the overall status comes from export, which usually succeeds. Assign first, then export: foo="$(mycmd)" and then export foo. Literal values such as export foo=bar do not have this problem.

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

```bash
#!/bin/bash
export foo="$(false)"
export BAR=$(date)
export FOO bar=$(cmd)
```

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

```bash
#!/bin/bash
foo="$(false)"
export foo

x=$(date)
export x

export PLAIN=literal

bar=$(cmd)
export FOO bar
```
  Seamless integrations. Try Datadog Code SecurityDatadog Code Security 
{% icon name="icon-external-link" /%}
 