Handle unbound arrays correctly 77/15677/3 v0.37.5
authorAnil Belur <abelur@linuxfoundation.org>
Tue, 14 May 2019 13:14:05 +0000 (23:14 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Tue, 14 May 2019 22:25:15 +0000 (22:25 +0000)
The change cfe54b794b3814f288009b796e82668ba8846ca1 missed
handling unbound arrays with `set -u`.

Issue: RELENG-2013
Change-Id: Ic37ce0404f13bff04aa4122c9b1c91add78e2145
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
releasenotes/notes/handle-unbound-arrays-9a31a444687d18ce.yaml [new file with mode: 0644]
shell/logs-deploy.sh

diff --git a/releasenotes/notes/handle-unbound-arrays-9a31a444687d18ce.yaml b/releasenotes/notes/handle-unbound-arrays-9a31a444687d18ce.yaml
new file mode 100644 (file)
index 0000000..1be44d8
--- /dev/null
@@ -0,0 +1,14 @@
+---
+fixes:
+  - |
+    Fix error with handling unbound arrays for search extensions, when using
+    `set -u`. The correct way of using this.
+
+    .. code-block:: bash
+
+       set -u
+       arr=()
+       echo "output: '${arr[@]}'"
+       bash: arr[@]: unbound variable
+       echo "output: '${arr[@]:-}'"
+       foo: ''
index a00f0a7..23660d7 100644 (file)
@@ -21,9 +21,10 @@ else
 
     # Handle multiple search extensions as separate values to '-p|--pattern'
     set -f # Disable pathname expansion
+    search_exts=()
     IFS=' ' read -r -a search_exts <<< "${ARCHIVE_ARTIFACTS:-}"
     pattern_opts=()
-    for search_ext in "${search_exts[@]}";
+    for search_ext in "${search_exts[@]:-}";
     do
         pattern_opts+=("-p" "$search_ext")
     done