fix(shell): avoid shared /tmp shell-init.log
This commit is contained in:
parent
85b21cc6ea
commit
38647526ff
1 changed files with 12 additions and 2 deletions
|
|
@ -1,7 +1,17 @@
|
||||||
# ---- logging ---------------------------------------------------------------
|
# ---- logging ---------------------------------------------------------------
|
||||||
|
|
||||||
log_shell_init() {
|
log_shell_init() {
|
||||||
printf '%s\n' "shell-init: $*" >>/tmp/shell-init.log 2>/dev/null || true
|
local uid="${UID:-}"
|
||||||
|
[[ -n "$uid" ]] || uid="$(id -u 2>/dev/null || echo unknown)"
|
||||||
|
|
||||||
|
# Avoid a shared logfile in /tmp: if it is ever created root-owned (e.g. from
|
||||||
|
# a root shell), user shells will spam "Permission denied" on every launch.
|
||||||
|
#
|
||||||
|
# Override with:
|
||||||
|
# export NANUQSAURUS_SHELL_INIT_LOG_FILE=/path/to/log
|
||||||
|
local log_file="${NANUQSAURUS_SHELL_INIT_LOG_FILE:-/tmp/shell-init-${uid}.log}"
|
||||||
|
|
||||||
|
printf '%s\n' "shell-init: $*" >>"$log_file" 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---- helpers ---------------------------------------------------------------
|
# ---- helpers ---------------------------------------------------------------
|
||||||
|
|
@ -126,4 +136,4 @@ fi
|
||||||
|
|
||||||
if have bat; then
|
if have bat; then
|
||||||
alias cat='bat --style=plain --pager=never' 2>/dev/null
|
alias cat='bat --style=plain --pager=never' 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue