auto-detect non-interactive mode when no terminal is present

chezmoi run_onchange scripts don't receive CLI arguments, so the
--non-interactive flag only works when running the script directly.
Now also checks if stdin/stdout are real terminals to auto-detect
non-interactive contexts like Vagrant provisioning.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Anton Volnuhin 2026-03-03 01:48:07 +03:00
parent 3e53d99ad2
commit a7f938591b

View File

@ -63,6 +63,11 @@ while [ $# -gt 0 ]; do
shift shift
done done
# Auto-detect non-interactive mode when no real terminal is present
if [ ! -t 0 ] || [ ! -t 1 ]; then
NON_INTERACTIVE=1
fi
# Timeout portability (macOS has gtimeout via coreutils, not timeout) # Timeout portability (macOS has gtimeout via coreutils, not timeout)
TIMEOUT_BIN="$(command -v timeout || command -v gtimeout || true)" TIMEOUT_BIN="$(command -v timeout || command -v gtimeout || true)"