fix(shell): disable init logging by default

This commit is contained in:
randogoth 2026-02-05 07:24:59 +02:00
parent 2f8f5e340b
commit e4fcf78b09

View file

@ -1,7 +1,22 @@
# ---- logging ---------------------------------------------------------------
log_shell_init() {
printf '%s\n' "shell-init: $*" >>/tmp/shell-init.log 2>/dev/null || true
# Disabled by default to avoid noisy permission errors in login shells.
# Enable with:
# export NANUQSAURUS_SHELL_INIT_LOG=1
# Optionally override the file path:
# export NANUQSAURUS_SHELL_INIT_LOG_FILE="$HOME/.local/state/shell-init.log"
[[ -n "${NANUQSAURUS_SHELL_INIT_LOG:-}" ]] || return 0
local uid="${UID:-}"
[[ -n "$uid" ]] || uid="$(id -u 2>/dev/null || echo unknown)"
local log_file="${NANUQSAURUS_SHELL_INIT_LOG_FILE:-${XDG_STATE_HOME:-$HOME/.local/state}/nanuqsaurus/shell-init-${uid}.log}"
local log_dir="${log_file%/*}"
mkdir -p "$log_dir" 2>/dev/null || return 0
# Redirect stderr first so a failing stdout redirection stays silent.
printf '%s\n' "shell-init: $*" 2>/dev/null >>"$log_file" || true
}
# ---- helpers ---------------------------------------------------------------