30 lines
1.2 KiB
Bash
30 lines
1.2 KiB
Bash
|
|
#!/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
|