---
title: Avoid ambiguous argument concatenation with $@ or ${name[@]}
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > Code Security > Static Code Analysis (SAST) > SAST
  Rules > Avoid ambiguous argument concatenation with $@ or ${name[@]}
---

# Avoid ambiguous argument concatenation with $@ or ${name[@]}

{% callout %}
# Important note for users on the following Datadog sites: app.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/ambiguous-argument-concatenation`

**Language:** Bash

**Severity:** Warning

**Category:** Code Style

## Description{% #description %}

Putting literal text and a list expansion (`$@` or `${name[@]}`) inside the same double-quoted word is ambiguous: Bash concatenates the literal with only the first and last expanded words in a surprising way, so the resulting argv is hard to predict and easy to get wrong.

Prefer separate arguments, use `$*` when a single string is acceptable, or quote only the literal so the list expansion stands alone.

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

```bash
#!/bin/bash
printf '%s\n' "Bad parameters: $@"
msg="$@tail"
echo "x ${v[@]}"
echo "${arr[@]}suffix"
```

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

```bash
#!/bin/bash
printf '%s\n' "$@"
printf '%s\n' "${files[@]}"
printf '%s\n' "Bad parameters: $*"
printf '%s\n' "Bad parameters: " "$@"
```
  Seamless integrations. Try Datadog Code SecurityDatadog Code Security 
{% icon name="icon-external-link" /%}
 