Created
June 29, 2023 20:51
-
-
Save pwtyler/0d037fd7a69e4cfe8e86df6dd5d7efe7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eou pipefail | |
# shellcheck disable=SC2155 | |
readonly WP_WORKSPACE=$(mktemp -d /tmp/wpworkspace_XXXXXXX) | |
# Trap any exit and print the temporary workspace path back to the terminal | |
trap 'echo " | |
Working Directory: ${WP_WORKSPACE}"' EXIT | |
wp core download --path="${WP_WORKSPACE}" | |
wp config create \ | |
--path="${WP_WORKSPACE}" \ | |
--dbname="foo" \ | |
--dbuser="foo" \ | |
--dbpass="foo" \ | |
--dbhost="localhost" \ | |
--skip-check \ | |
--extra-php << PHP | |
trigger_error('Take Note.', E_USER_NOTICE); | |
trigger_error('You have been warned.', E_USER_WARNING); | |
PHP | |
cd "${WP_WORKSPACE}" | |
echo "> Notices are printed twice" | |
wp config get table_prefix | |
echo | |
echo "> Redirecting Stderr works, but errors are also in stdout" | |
wp config get table_prefix 2> /dev/null | |
echo | |
echo "> Capturing the command output for future use is broken notices" | |
PREFIX=$(wp config get table_prefix 2> /dev/null) | |
echo "${PREFIX}" | |
echo | |
echo "> Sending only stdout to a file also sends errors" | |
wp config get table_prefix > ./prefix.txt | |
echo --- | |
cat prefix.txt | |
echo | |
cd - | |
echo "end of script" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment