Ce produit n'est pas pris en charge pour le site Datadog que vous avez sélectionné. ().
Cette page n'est pas encore disponible en français. Nous travaillons sur sa traduction.
Si vous avez des questions ou des commentaires concernant notre projet de traduction actuel, n'hésitez pas à nous contacter !

Metadata

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

Language: Bash

Severity: Warning

Category: Best Practices

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

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

Compliant Code Examples

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

x=$(date)
export x

export PLAIN=literal

bar=$(cmd)
export FOO bar
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Intégrations fluides. Essayez Datadog Code Security