fix: resolve ShellCheck violations in shell scripts (#91)
- SC2155 (bin/localwp-setup.sh): declare local variables separately from command substitution assignments to avoid masking return values (13 fixes) - SC2034 (bin/localwp-setup.sh): remove unused PLUGIN_TEXT_DOMAIN variable - SC2162 (bin/localwp-setup.sh): add -r flag to read to avoid backslash mangling - SC2154 (bin/setup-test-env.sh): add shellcheck disable for PHP variables in heredoc that ShellCheck incorrectly identifies as unassigned shell variables - bin/setup-test-env.sh: remove self-modifying chmod +x $0 (unnecessary and bad practice; file permissions should be set once in version control) - bin/setup-test-env.sh: change == to = in POSIX [ ] test expressions - build.sh: add ./ prefix to directory glob copies for clarity - build.sh: use subshell (cd build || exit 1; zip ...) instead of bare cd/cd.. to avoid SC2103 and ensure working directory is always restored Fixes part of #20 (shell script quality issues)
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Make this script executable
|
||||
chmod +x "$0"
|
||||
|
||||
# Check if environment type is provided
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $0 [single|multisite|playground-single|playground-multisite]"
|
||||
@@ -49,7 +46,7 @@ install_wp_playground() {
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$ENV_TYPE" == "single" ]; then
|
||||
if [ "$ENV_TYPE" = "single" ]; then
|
||||
echo "Setting up single site environment..."
|
||||
|
||||
# Install wp-env if needed
|
||||
@@ -83,7 +80,7 @@ if [ "$ENV_TYPE" == "single" ]; then
|
||||
echo "Site: http://localhost:8888"
|
||||
echo "Admin login: admin / password"
|
||||
|
||||
elif [ "$ENV_TYPE" == "multisite" ]; then
|
||||
elif [ "$ENV_TYPE" = "multisite" ]; then
|
||||
echo "Setting up multisite environment..."
|
||||
|
||||
# Install wp-env if needed
|
||||
@@ -124,7 +121,7 @@ elif [ "$ENV_TYPE" == "multisite" ]; then
|
||||
echo "Test site: http://localhost:8888/testsite"
|
||||
echo "Admin login: admin / password"
|
||||
|
||||
elif [ "$ENV_TYPE" == "playground-single" ]; then
|
||||
elif [ "$ENV_TYPE" = "playground-single" ]; then
|
||||
echo "Setting up WordPress Playground single site environment..."
|
||||
|
||||
# Install wp-playground if needed
|
||||
@@ -193,7 +190,7 @@ EOF
|
||||
echo "Admin login: admin / password"
|
||||
echo "Press Ctrl+C to stop the server when done."
|
||||
|
||||
elif [ "$ENV_TYPE" == "playground-multisite" ]; then
|
||||
elif [ "$ENV_TYPE" = "playground-multisite" ]; then
|
||||
echo "Setting up WordPress Playground multisite environment..."
|
||||
|
||||
# Install wp-playground if needed
|
||||
@@ -205,6 +202,7 @@ elif [ "$ENV_TYPE" == "playground-multisite" ]; then
|
||||
zip -r dist/plugin.zip . -x "node_modules/*" "dist/*" ".git/*"
|
||||
|
||||
# Update blueprint to use local plugin
|
||||
# shellcheck disable=SC2154
|
||||
cat >playground/multisite-blueprint.json <<EOF
|
||||
{
|
||||
"landingPage": "/wp-admin/network/",
|
||||
|
||||
Reference in New Issue
Block a user