Import josh-sync from subrepo/main

Sync-Origin: import/josh-sync/20260528-041502
This commit is contained in:
sync-bot
2026-05-28 04:15:02 +01:00
commit b35703d271
47 changed files with 6418 additions and 0 deletions

29
lib/core.sh Normal file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# lib/core.sh — Foundation: logging, exit codes, git environment isolation
#
# Source this first. All other modules depend on it.
set -euo pipefail
# ─── Exit Codes ─────────────────────────────────────────────────────
readonly E_GENERAL=1
# ─── Logging ────────────────────────────────────────────────────────
# All log output goes to stderr. Sync functions use stdout for return values.
log() {
local level="$1"; shift
echo "$(date -u +%H:%M:%S) [${level}] $*" >&2
}
die() { log "FATAL" "$@"; exit "$E_GENERAL"; }
# ─── Git Environment Isolation ──────────────────────────────────────
# Prevent user/system config from interfering with sync operations.
# Safe because josh-sync always runs as a subprocess, never sourced into
# an interactive shell.
export GIT_CONFIG_GLOBAL=/dev/null
export GIT_CONFIG_SYSTEM=/dev/null
export GIT_TERMINAL_PROMPT=0