From db4cb7f1eaa5ed259eb5b99b902f2495b3e6ab4b Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 25 Feb 2020 14:29:28 -0500 Subject: [PATCH] tests: fix shellcheck warning in plugins/src.ctf.lttng-live/test_live shellcheck says: In test_live line 143: if ! "$BT_TESTS_BT2_BIN" $cli_args 1>"$cli_stdout_file" 2>"$cli_stderr_file"; then ^-------^ SC2086: Double quote to prevent globbing and word splitting. Did you mean: if ! "$BT_TESTS_BT2_BIN" "$cli_args" 1>"$cli_stdout_file" 2>"$cli_stderr_file"; then In this case, we do want to pass the $cli_args string as multiple arguments, so we don't want to just double-quote it. Circumvent the warning by splitting it explicitly into an array, then passing the array using array expansion. I think this is clearer anyway, as it shows the intent of splitting the arguments more explicitly than relying in the implicit splitting done by the shell. Also, change it to use bt_cli, instead of running the babeltrace binary by hand. Change-Id: Idd277fc792e9a426213932566c3c096a53b56d9e Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/3140 Tested-by: jenkins --- tests/plugins/src.ctf.lttng-live/test_live | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/plugins/src.ctf.lttng-live/test_live b/tests/plugins/src.ctf.lttng-live/test_live index 891ce45a..b06a72ef 100755 --- a/tests/plugins/src.ctf.lttng-live/test_live +++ b/tests/plugins/src.ctf.lttng-live/test_live @@ -139,8 +139,10 @@ get_cli_output_with_lttng_live_server() { cli_args=${cli_args_template//@PORT@/$port} - diag "Running CLI: 'babeltrace2 $cli_args'" - if ! "$BT_TESTS_BT2_BIN" $cli_args 1>"$cli_stdout_file" 2>"$cli_stderr_file"; then + # Split argument string by spaces into an array. + IFS=' ' read -ra cli_args <<< "$cli_args" + + if ! bt_cli "$cli_stdout_file" "$cli_stderr_file" "${cli_args[@]}"; then # CLI failed: cancel everything else kill_lttng_live_server "$server_pid_file" wait -- 2.34.1