diff --git a/SC2145.md b/SC2145.md index 311caab..05550a4 100644 --- a/SC2145.md +++ b/SC2145.md @@ -12,6 +12,18 @@ printf "Error: %s\n" "Bad parameters: $@" printf "Error: %s\n" "Bad parameters: $*" ``` +### Problematic code 2: + +```sh +printf "Error: %s\n" "Bad parameters: ${ARRAY_VAR[@]}" +``` + +### Correct code 2: + +```sh +printf "Error: %s\n" "Bad parameters: " "${ARRAY_VAR[@]}" +``` + ### Rationale: The behavior when concatenating a string and array is rarely intended. The preceeding string is prefixed to the first array element, while the succeeding string is appended to the last one. The middle array elements are unaffected.