WP-CLI: Detecting warnings from verify-checksums
-
I have a Bash script which runs the following commands to check that the current WordPress installation has valid checksums, and then updates core, all plugins, and all themes.
#!/bin/bash set -e set -u set -o pipefail readonly WP_SITE=$1 readonly SITE_PATH=/srv/${WP_SITE}/public/htdocs if [ ! -d ${SITE_PATH} ]; then echo "Site path does not exist: ${SITE_PATH}" exit 1 fi echo "Verifying checksums for ${WP_SITE}" /usr/bin/php ${HOME}/bin/wp-cli.phar core verify-checksums --path=${SITE_PATH} echo "Updating core, plugins and themes for ${WP_SITE}" /usr/bin/php ${HOME}/bin/wp-cli.phar core update --path=${SITE_PATH} /usr/bin/php ${HOME}/bin/wp-cli.phar plugin update --all --path=${SITE_PATH} /usr/bin/php ${HOME}/bin/wp-cli.phar theme update --all --path=${SITE_PATH}What I’m having trouble with is preventing the three update commands from running if the verify-checksums command returns any warnings or errors.
For errors this isn’t a problem, as WP-CLI returns a non-zero exit code and I have
set -ewhich will catch this and halt the script. However, for warnings WP-CLI returns a zero exit code, which indicates that the command completed successfully.Is there a way to achieve what I want? I did look to see if there was an option to turn warnings into errors, similar to
-Werrorin GCC, but this doesn’t appear to be the case.I’m using WP-CLI 2.4.0, which is the current stable version according to the website.
The topic ‘WP-CLI: Detecting warnings from verify-checksums’ is closed to new replies.