"#"
This commit is contained in:
32
lib/core.sh
Normal file
32
lib/core.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/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_OK=0
|
||||
readonly E_GENERAL=1
|
||||
readonly E_CONFIG=10
|
||||
readonly E_AUTH=11
|
||||
|
||||
# ─── 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
|
||||
Reference in New Issue
Block a user