edge-host: fix settings-backup terminator check (trailing newline) #121
@@ -11,8 +11,9 @@ bak="$src.bak"
|
||||
|
||||
# Only back up a plausibly-intact file: non-empty and JSON-object-terminated.
|
||||
# This avoids overwriting a good backup with a truncated (mid-write) file.
|
||||
# Ignore trailing whitespace — settings.json ends with "}\n".
|
||||
[ -s "$src" ] || { echo "settings.json missing/empty — skip"; exit 0; }
|
||||
[ "$(tail -c1 "$src")" = "}" ] || { echo "settings.json not }-terminated (mid-write?) — skip"; exit 0; }
|
||||
[ "$(tail -c 64 "$src" | tr -d '[:space:]' | tail -c1)" = "}" ] || { echo "settings.json not }-terminated (mid-write?) — skip"; exit 0; }
|
||||
|
||||
# Skip if unchanged since the last backup.
|
||||
if [ -f "$bak" ] && cmp -s "$src" "$bak"; then
|
||||
|
||||
Reference in New Issue
Block a user