From 4ec25444335fa4ce681de4121b87c3106f843347 Mon Sep 17 00:00:00 2001 From: ebersphi Date: Wed, 4 Mar 2020 16:51:05 +0100 Subject: [PATCH] Updated SC2124 (markdown) --- SC2124.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SC2124.md b/SC2124.md index 183a94f..76534cb 100644 --- a/SC2124.md +++ b/SC2124.md @@ -50,3 +50,13 @@ The same is true for `${@: -1}`, which results in 0 or 1 elements: `var=${*: -1} ### Exceptions None. + +### Adding an element to an array may trigger this warning when you forget the parenthesis. +``` +filelist="${filelist[@]}" "$filename" +``` +What was meant is: +``` +filelist=("${filelist[@]}" "$filename") +``` +Note: this syntax is compatible with older shells, in later shells (bash 3.1+ and zsh 4.2+) you can do: ```filelist+=("$filename")```