hall-announce --clear leaves an empty notice rather than no file, so no page's check is a failed request
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
96ec6861d5
commit
567590464e
@@ -10,9 +10,11 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
FILE=/var/lib/hall/announcement.json
|
FILE=/var/lib/hall/announcement.json
|
||||||
|
|
||||||
|
# No notice is an empty one, {}, never a missing file: a page's check for a missing file
|
||||||
|
# is a failed request, and the browser reports it in every visitor's console.
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--clear) rm -f "$FILE"; echo "cleared."; exit 0 ;;
|
--clear) mkdir -p "$(dirname "$FILE")"; echo '{}' > "$FILE.tmp"; chmod 644 "$FILE.tmp"; mv "$FILE.tmp" "$FILE"; echo "cleared."; exit 0 ;;
|
||||||
--show) cat "$FILE" 2>/dev/null || echo "no announcement."; exit 0 ;;
|
--show) if grep -q '"text"' "$FILE" 2>/dev/null; then cat "$FILE"; else echo "no announcement."; fi; exit 0 ;;
|
||||||
''|-*) sed -n '2,9p' "$0" | sed 's/^# \{0,1\}//'; exit 2 ;;
|
''|-*) sed -n '2,9p' "$0" | sed 's/^# \{0,1\}//'; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user