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 24, 2021
1 parent d566a36 commit d248c24
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/commands/command-plugin-test.bash
Expand Up @@ -8,8 +8,7 @@ plugin_test_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 @@ -30,7 +29,9 @@ plugin_test_command() {
esac
done

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

local exit_code
local TEST_DIR
Expand Down Expand Up @@ -128,11 +129,11 @@ plugin_test_command() {
fail_test "could not reshim plugin"
fi

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

Expand Down

0 comments on commit d248c24

Please sign in to comment.