From 7f97fe98a9a2b65d506ab88579afbbf04810308a Mon Sep 17 00:00:00 2001 From: Nathan Arthur Date: Thu, 29 Jul 2021 10:04:35 -0400 Subject: [PATCH] Show examples of how this works with globs, and warn about POSIX --- SC2125.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SC2125.md b/SC2125.md index 5b877e9..b861374 100644 --- a/SC2125.md +++ b/SC2125.md @@ -4,7 +4,11 @@ ```sh foo={1..9} -echo $foo +echo "$foo" +``` +```sh +foo="/some/path/*" +echo "$foo" ``` ### Correct code: @@ -13,6 +17,12 @@ echo $foo foo=( {1..9} ) echo "${foo[@]}" ``` +```sh +foo=(/some/path/*) +echo "${foo[@]}" +``` + +Note that either of these will trigger SC3030 ("In POSIX sh, array references are undefined") if you are using `sh` and not e.g. `bash`. ### Rationale: