Skip to content

Commit 8dfe193

Browse files
DRY shell arg escaping and simplify console functions
You don't need to treat an empty array separately from another in the case of passing the arguments to a function/command
1 parent dbca958 commit 8dfe193

File tree

4 files changed

+4
-20
lines changed

4 files changed

+4
-20
lines changed

magento2/usr/local/share/container/baseimage-30.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,5 @@ fi
8787

8888
do_magento() (
8989
set +x
90-
if [ "$#" -gt 0 ]; then
91-
as_app_user "./bin/magento $(printf "%q " "$@")"
92-
else
93-
as_app_user "./bin/magento"
94-
fi
90+
as_app_user "$(escape_shell_args ./bin/magento "$@")"
9591
)

spryker/usr/local/share/spryker/spryker_functions.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,5 @@ do_spryker_run_tests() {
159159

160160
do_spryker_console() (
161161
set +x
162-
if [ "$#" -gt 0 ]; then
163-
as_app_user "vendor/bin/console $(printf "%q " "$@")"
164-
else
165-
as_app_user "vendor/bin/console"
166-
fi
162+
as_app_user "$(escape_shell_args vendor/bin/console "$@")"
167163
)

symfony/usr/local/share/symfony/symfony_functions.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,5 @@ do_symfony_build() {
149149

150150
do_symfony_console() (
151151
set +x
152-
if [ "$#" -gt 0 ]; then
153-
as_app_user "'$SYMFONY_CONSOLE' $(printf "%q " "$@")"
154-
else
155-
as_app_user "'$SYMFONY_CONSOLE'"
156-
fi
152+
as_app_user "$(escape_shell_args "$SYMFONY_CONSOLE" "$@")"
157153
)

ubuntu/16.04/usr/local/share/bootstrap/common_functions.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,5 @@ function do_list_functions() {
281281
}
282282

283283
function do_shell() {
284-
if [ "$#" -gt 0 ]; then
285-
bash "$@"
286-
else
287-
bash
288-
fi
284+
bash "$@"
289285
}

0 commit comments

Comments
 (0)