Files
josh-sync/lib/core.sh
Slim B 0d2aea9664 Fix all shellcheck warnings for nix build gate
- SC2015: Wrap A && B || C patterns in brace groups for directive scope
- SC2064: Suppress for intentional early trap expansion (local vars)
- SC2164: Add || exit to cd commands in subshells
- SC2001: Suppress for sed URL injection (clearer than parameter expansion)
- SC1083: Handle {tree} git syntax (quote or suppress)
- SC1091: Suppress for runtime-resolved source paths
- SC2034: Remove unused exit codes (E_OK, E_CONFIG, E_AUTH)
- SC2116: Eliminate useless echo in mono_auth_url construction

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 14:33:26 +03:00

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