Skip to content

Commit d469527

Browse files
committed
reduce noise and correct shellcheck issues
1 parent 58fbeec commit d469527

File tree

2 files changed

+43
-11
lines changed

2 files changed

+43
-11
lines changed

setup-wordpress.sh

+24-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
#!/bin/bash
2+
#
3+
# Notes:
4+
# - docker compose run redirects the stderr of any invoked executables to
5+
# stdout. The only messages that will appear on stderr are issued by docker
6+
# compose run itself. This appears to be an undocumented "feature":
7+
# https://docs.docker.com/engine/reference/commandline/compose_run/
8+
#
9+
# The "2>/dev/null" below silences the messages from docker compose run.
10+
# For example, the output like the following will not be visible:
11+
# [+] Creating 2/0
12+
# ✔ Container cc-wordpress-db Running 0.0s
13+
# ✔ Container cc-web Running 0.0s
14+
#
215
set -o errexit
316
set -o errtrace
417
set -o nounset
518

19+
# shellcheck disable=SC2154
620
trap '_es=${?};
721
printf "${0}: line ${LINENO}: \"${BASH_COMMAND}\"";
822
printf " exited with a status of ${_es}\n";
923
exit ${_es}' ERR
1024

25+
# shellcheck disable=SC1091
1126
source .env
1227
ACTIVATE_PLUGINS='
1328
acf-menu-chooser
@@ -61,7 +76,7 @@ activate_themes() {
6176

6277
composer_install() {
6378
header 'Composer install'
64-
docker compose run --rm composer install
79+
docker compose run --rm composer install 2>/dev/null
6580
echo
6681
}
6782

@@ -80,7 +95,7 @@ enable_permalinks() {
8095

8196
error_exit() {
8297
# Echo error message and exit with error
83-
echo -e "\033[31mERROR:\033[0m ${@}" 1>&2
98+
echo -e "\033[31mERROR:\033[0m ${*}" 1>&2
8499
exit 1
85100
}
86101

@@ -123,7 +138,7 @@ install_wordpress() {
123138

124139
utils_info() {
125140
header 'Utilities info'
126-
docker compose run --rm composer --version
141+
docker compose run --rm composer --version 2>/dev/null
127142
wpcli --info
128143
echo
129144
}
@@ -150,12 +165,14 @@ wordpress_status() {
150165

151166

152167
wpcli() {
168+
# Call WP-CLI with appropriate site arguments via Docker
153169
docker compose run --rm \
154-
--env WP_ADMIN_USER=${WP_ADMIN_USER} \
155-
--env WP_ADMIN_PASS=${WP_ADMIN_PASS} \
156-
--env WP_ADMIN_EMAIL=${WP_ADMIN_EMAIL} \
170+
--env WP_ADMIN_USER="${WP_ADMIN_USER}" \
171+
--env WP_ADMIN_PASS="${WP_ADMIN_PASS}" \
172+
--env WP_ADMIN_EMAIL="${WP_ADMIN_EMAIL}" \
157173
wordpress-cli \
158-
/usr/local/bin/wp --path=${WEB_WP_DIR} --url=${WEB_WP_URL} "${@}"
174+
/usr/local/bin/wp --path="${WEB_WP_DIR}" --url="${WEB_WP_URL}" \
175+
"${@}" 2>/dev/null
159176
}
160177

161178

wpcli.sh

+19-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ set -o errexit
33
set -o errtrace
44
set -o nounset
55

6+
# shellcheck disable=SC2154
67
trap '_es=${?};
78
printf "${0}: line ${LINENO}: \"${BASH_COMMAND}\"";
89
printf " exited with a status of ${_es}\n";
910
exit ${_es}' ERR
1011

12+
# shellcheck disable=SC1091
1113
source .env
1214
WEB_WP_DIR=/var/www/html
1315
WEB_WP_URL=http://localhost:8080
@@ -17,12 +19,25 @@ WEB_WP_URL=http://localhost:8080
1719

1820

1921
wpcli() {
22+
# Call WP-CLI with appropriate site arguments via Docker
23+
#
24+
# docker compose run redirects the stderr of any invoked executables to
25+
# stdout. The only messages that will appear on stderr are issued by
26+
# docker compose run itself. This appears to be an undocumented "feature":
27+
# https://docs.docker.com/engine/reference/commandline/compose_run/
28+
#
29+
# The "2>/dev/null" below silences the messages from docker compose run.
30+
# For example, the output like the following will not be visible:
31+
# [+] Creating 2/0
32+
# ✔ Container cc-wordpress-db Running 0.0s
33+
# ✔ Container cc-web Running 0.0s
2034
docker compose run --rm \
21-
--env WP_ADMIN_USER=${WP_ADMIN_USER} \
22-
--env WP_ADMIN_PASS=${WP_ADMIN_PASS} \
23-
--env WP_ADMIN_EMAIL=${WP_ADMIN_EMAIL} \
35+
--env WP_ADMIN_USER="${WP_ADMIN_USER}" \
36+
--env WP_ADMIN_PASS="${WP_ADMIN_PASS}" \
37+
--env WP_ADMIN_EMAIL="${WP_ADMIN_EMAIL}" \
2438
wordpress-cli \
25-
/usr/local/bin/wp --path=${WEB_WP_DIR} --url=${WEB_WP_URL} "${@}"
39+
/usr/local/bin/wp --path="${WEB_WP_DIR}" --url="${WEB_WP_URL}" \
40+
"${@}" 2>/dev/null
2641
}
2742

2843

0 commit comments

Comments
 (0)