FIX: Correct sed insert syntax in add_disable_wpcron_to_config

Problem: @ delimiter not valid for sed i/a commands, caused unknown command error
Solution: Use proper sed syntax with forward slash and literal newline after backslash

The i and a commands in sed require a literal newline after the backslash.
Fixed by using actual newlines in the here-doc style syntax.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
cschantz
2026-03-03 00:37:29 -05:00
parent 842e5dea03
commit 71d724d5f8
@@ -1589,12 +1589,14 @@ add_disable_wpcron_to_config() {
# Try to insert before WordPress stop editing comment (proper convention) # Try to insert before WordPress stop editing comment (proper convention)
if grep -q "$WP_CONFIG_MARKER" "$wp_config" 2>/dev/null; then if grep -q "$WP_CONFIG_MARKER" "$wp_config" 2>/dev/null; then
# Use sed with @ delimiter to avoid escaping issues, insert before marker # Use sed with proper newline syntax for insert command
sed -i.wpbak "@$WP_CONFIG_MARKER@i\\$new_define" "$wp_config" sed -i.wpbak "/$WP_CONFIG_MARKER/i\\
$new_define" "$wp_config"
return 0 return 0
elif grep -q "$WP_EDIT_START" "$wp_config"; then elif grep -q "$WP_EDIT_START" "$wp_config"; then
# Fallback: if no stop editing found, add after opening PHP tag # Fallback: if no stop editing found, add after opening PHP tag
sed -i.wpbak "@$WP_EDIT_START@a\\$new_define" "$wp_config" sed -i.wpbak "/$WP_EDIT_START/a\\
$new_define" "$wp_config"
return 0 return 0
else else
# File format is unexpected # File format is unexpected