fix(script): Use standard GNU sed -i syntax for self-update

This commit is contained in:
courtmanr@gmail.com
2025-05-01 14:43:11 +01:00
parent f5984db292
commit 2780fd8a9f
+4 -4
View File
@@ -231,8 +231,8 @@ self_update_check() {
print_info "[DEBUG] Updating embedded SHA in temp script to $latest_remote_sha..."
# Use sed to find the line starting with CURRENT_SCRIPT_COMMIT_SHA= and replace the quoted value
# Using # as delimiter for sed to avoid issues with slashes in SHAs (unlikely, but safe)
# Use -i '' for BSD sed compatibility (macOS) and -e to explicitly provide the script
sed -i '' -e "s#^CURRENT_SCRIPT_COMMIT_SHA=.*#CURRENT_SCRIPT_COMMIT_SHA=\"$latest_remote_sha\"#" "$temp_script"
# Use -i for GNU sed (Linux) and -e to explicitly provide the script
sed -i -e "s#^CURRENT_SCRIPT_COMMIT_SHA=.*#CURRENT_SCRIPT_COMMIT_SHA=\"$latest_remote_sha\"#" "$temp_script"
local update_sha_exit_code=$?
if [ $update_sha_exit_code -ne 0 ]; then
print_error "sed command failed while updating embedded SHA! Aborting update."
@@ -244,8 +244,8 @@ self_update_check() {
# ---> Fix line endings on TEMP file < ---
# Keep this step to ensure downloaded script content is clean
# Use -i '' for macOS compatibility
sed -i '' 's/\r$//' "$temp_script"
# Use -i for GNU sed (Linux)
sed -i 's/\r$//' "$temp_script"
local sed_exit_code=$?
if [ $sed_exit_code -ne 0 ]; then
print_error "sed command failed! Cannot fix line endings. Aborting."