Skip to content

Commit 9508d7f

Browse files
authored
Merge pull request #363 from wp-cli/copilot/sub-pr-356-again
2 parents 88e06b0 + c8af7e1 commit 9508d7f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

templates/install-wp-tests.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ WP_CORE_FILE="$WP_CORE_DIR"/wp-settings.php
3131
download() {
3232
if command -v curl > /dev/null 2>&1; then
3333
curl -L -s "$1" > "$2";
34+
return $?
3435
elif command -v wget > /dev/null 2>&1; then
3536
wget -nv -O "$2" "$1"
37+
return $?
3638
else
3739
echo -e "${RED}Error: Neither curl nor wget is installed.${RESET}"
3840
exit 1
@@ -43,10 +45,14 @@ check_for_updates() {
4345
local remote_url="https://raw.githubusercontent.com/wp-cli/scaffold-command/main/templates/install-wp-tests.sh"
4446
local tmp_script="$TMPDIR/install-wp-tests.sh.latest"
4547

46-
download "$remote_url" "$tmp_script"
48+
if ! download "$remote_url" "$tmp_script"; then
49+
echo -e "${YELLOW}Warning: Failed to download the latest version of the script for update check.${RESET}"
50+
return
51+
fi
4752

48-
if [ ! -f "$tmp_script" ]; then
49-
echo -e "${YELLOW}Warning: Could not download the latest version of the script for update check.${RESET}"
53+
if [ ! -f "$tmp_script" ] || [ ! -s "$tmp_script" ]; then
54+
echo -e "${YELLOW}Warning: Downloaded script is missing or empty, cannot check for updates.${RESET}"
55+
rm -f "$tmp_script"
5056
return
5157
fi
5258

0 commit comments

Comments
 (0)