From 5b6f3f26e067c2f67864d93b26ef2f6fad41da36 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 11 Sep 2013 11:46:48 +0000 Subject: [PATCH] sensors-detect: Detect incorrect non-interactive runs It is better to use option --auto for non-interactive runs of the sensors-detect script than faking an input to get the default answers to all questions. --- CHANGES | 1 + prog/detect/sensors-detect | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 1a247ad6..d392de15 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,7 @@ SVN HEAD Add detection of F71868A Add a PCI ID for new family 15h AMD processors Introduce automatic mode (--auto) + Detect incorrect non-interactive runs 3.3.4 (2013-05-27) sensors.conf.5: Mention "sensors -u" to get the raw feature names diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index b8e2b026..34ef5347 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -2517,7 +2517,7 @@ sub read_answer print "\n"; return ""; } - return ; + return || ""; } ################### @@ -7012,6 +7012,15 @@ sub main } unload_modules(); + + # Check if running non-interactively without --auto + if (!$opt{auto} && ! -t STDIN) { + print "***************************************************************\n". + "Warning: the preferred way to run this script non-interactively\n". + "is with option --auto. Other methods are discouraged and may\n". + "stop working at some point in the future.\n". + "***************************************************************\n\n"; + } } sub cleanup_on_int