Skip to content

Commit

Permalink
fix: Quote commands correctly in plugin-test
Browse files Browse the repository at this point in the history
  • Loading branch information
raxod502 committed Oct 25, 2021
1 parent d566a36 commit add6df8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/commands/command-plugin-test.bash
Expand Up @@ -4,12 +4,10 @@ plugin_test_command() {

local plugin_name=$1
local plugin_url=$2
local plugin_command_array=()
local plugin_command
local plugin_command=()
local plugin_gitref="master"
local tool_version
# shellcheck disable=SC2086
set -- ${*:3}
shift 2

while [[ $# -gt 0 ]]; do
case $1 in
Expand All @@ -24,13 +22,15 @@ plugin_test_command() {
shift # past value
;;
*)
plugin_command_array+=("$1") # save it in an array for later
plugin_command+=("$1") # save it in an array for later
shift # past argument
;;
esac
done

plugin_command="${plugin_command_array[*]}"
if [ "${#plugin_command[@]}" -eq 1 ]; then
plugin_command=(sh -c "${plugin_command[@]}")
fi

local exit_code
local TEST_DIR
Expand Down Expand Up @@ -129,10 +129,10 @@ plugin_test_command() {
fi

if [ -n "$plugin_command" ]; then
$plugin_command
"${plugin_command[@]}"
exit_code=$?
if [ $exit_code != 0 ]; then
fail_test "$plugin_command failed with exit code $?"
fail_test "$plugin_command[*] failed with exit code $?"
fi
fi

Expand Down

0 comments on commit add6df8

Please sign in to comment.