Skip to content

Commit 5dba22a

Browse files
author
Greg Bowler
committed
Use arrays instead of string concatenation
1 parent 76f35f7 commit 5dba22a

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

phpunit-action.bash

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,81 +13,81 @@ phar_url="${phar_url}.phar"
1313
curl -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "${github_action_path}/phpunit.phar"
1414
chmod +x "${github_action_path}/phpunit.phar"
1515

16-
command_string="phpunit"
16+
command_string=("phpunit")
1717

1818
if [ -n "$ACTION_CONFIGURATION" ]
1919
then
20-
command_string="$command_string --configuration $ACTION_CONFIGURATION"
20+
command_string+=("--configuration '$ACTION_CONFIGURATION'")
2121
fi
2222

2323
if [ -n "$ACTION_LOG_JUNIT" ]
2424
then
25-
command_string="$command_string --log-junit '$ACTION_LOG_JUNIT'"
25+
command_string+=("--log-junit '$ACTION_LOG_JUNIT'")
2626
fi
2727

2828
if [ -n "$ACTION_TESTDOX_HTML" ]
2929
then
30-
command_string="$command_string --testdox-html '$ACTION_TESTDOX_HTML'"
30+
command_string+=("--testdox-html '$ACTION_TESTDOX_HTML'")
3131
fi
3232

3333
if [ -n "$ACTION_TESTDOX_TEXT" ]
3434
then
35-
command_string="$command_string --testdox-text '$ACTION_TESTDOX_TEXT'"
35+
command_string+=("--testdox-text '$ACTION_TESTDOX_TEXT'")
3636
fi
3737

3838
if [ -n "$ACTION_TESTDOX_XML" ]
3939
then
40-
command_string="$command_string --testdox-xml '$ACTION_TESTDOX_XML'"
40+
command_string+=("--testdox-xml '$ACTION_TESTDOX_XML'")
4141
fi
4242

4343
if [ -n "$ACTION_BOOTSTRAP" ]
4444
then
45-
command_string="$command_string --bootstrap $ACTION_BOOTSTRAP"
45+
command_string+=("--bootstrap $ACTION_BOOTSTRAP")
4646
fi
4747

4848
if [ -n "$ACTION_FILTER" ]
4949
then
50-
command_string="$command_string --filter '$ACTION_FILTER'"
50+
command_string+=("--filter '$ACTION_FILTER'")
5151
fi
5252

5353
if [ -n "$ACTION_TESTSUITE" ]
5454
then
55-
command_string="$command_string --testsuite '$ACTION_TESTSUITE'"
55+
command_string+=("--testsuite '$ACTION_TESTSUITE'")
5656
fi
5757

5858
if [ -n "$ACTION_GROUP" ]
5959
then
60-
command_string="$command_string --group '$ACTION_GROUP'"
60+
command_string+=("--group '$ACTION_GROUP'")
6161
fi
6262

6363
if [ -n "$ACTION_EXCLUDE_GROUP" ]
6464
then
65-
command_string="$command_string --exclude-group '$ACTION_EXCLUDE_GROUP'"
65+
command_string+=("--exclude-group '$ACTION_EXCLUDE_GROUP'")
6666
fi
6767

6868
if [ -n "$ACTION_TEST_SUFFIX" ]
6969
then
70-
command_string="$command_string --test-suffix '$ACTION_TEST_SUFFIX'"
70+
command_string+=("--test-suffix '$ACTION_TEST_SUFFIX'")
7171
fi
7272

7373
if [ -n "$ACTION_WHITELIST" ]
7474
then
75-
command_string="$command_string --whitelist '$ACTION_WHITELIST'"
75+
command_string+=("--whitelist '$ACTION_WHITELIST'")
7676
fi
7777

7878
if [ -n "$ACTION_MEMORY_LIMIT" ]
7979
then
80-
command_string="$command_string -d memory_limit=$ACTION_MEMORY_LIMIT"
80+
command_string+=("-d memory_limit=$ACTION_MEMORY_LIMIT")
8181
fi
8282

8383
if [ -n "$ACTION_ARGS" ]
8484
then
85-
command_string="$command_string $ACTION_ARGS"
85+
command_string+=("$ACTION_ARGS")
8686
fi
8787

88-
echo "Command: $command_string"
88+
echo "Command: " "${command_string[@]}"
8989
docker run --rm \
9090
--volume "${github_action_path}/phpunit.phar":/usr/local/bin/phpunit \
9191
--volume "${GITHUB_WORKSPACE}":/app \
9292
--workdir /app \
93-
${docker_tag} ${command_string}
93+
${docker_tag} "${command_string[@]}"

0 commit comments

Comments
 (0)