When you call bt_diff_details_ctf_single() or
bt_diff_details_ctf_gen_single(), it is possible that you don't provide
any extra `sink.text.details` arguments. This makes
`${extra_details_args[@]}` empty.
`utils.sh` does
set -u
to make Bash throw an error when a variable is undefined/unbound.
Starting from Bash 4.4 [1]:
> Using ${a[@]} or ${a[*]} with an array without any assigned elements
> when the nounset option is enabled no longer throws an unbound
> variable error.
In bt_diff_details_ctf_single() and bt_diff_details_ctf_gen_single(), we
use `"${extra_details_args[@]}"` directly: Bash < 4.4 throws an error if
the array is empty.
We don't get this error on CI nodes having Bash < 4.4 currently because
all the usages of bt_diff_details_ctf_single() and
bt_diff_details_ctf_gen_single() pass extra `sink.text.details`
arguments. However it is my understanding that they are optional.
This patch replaces
"${extra_details_args[@]}"
with
${extra_details_args[@]+"${extra_details_args[@]}"}
so that `"${extra_details_args[@]}"` is only used when
`${extra_details_args[@]}` is defined. This works with any Bash version.
[1]: https://git.savannah.gnu.org/cgit/bash.git/tree/CHANGES?id=
3ba697465bc74fab513a26dea700cc82e9f4724e#n878
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic74117607ac616f3e27968a6f8fb09d07fe7eb12
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2080
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>