diff --git a/CHANGES b/CHANGES index d392de15..ca2d1cda 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,7 @@ SVN HEAD Add a PCI ID for new family 15h AMD processors Introduce automatic mode (--auto) Detect incorrect non-interactive runs + Rework option handling 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 34ef5347..a0f763b2 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -6824,14 +6824,22 @@ sub main { my ($input, $superio_features); - # Handle special command line cases first - if (defined $ARGV[0] && $ARGV[0] eq "--stat") { - show_i2c_stats(); - exit 0; + # Parse command line options + while (defined $ARGV[0]) { + if ($ARGV[0] eq "--stat") { + $opt{stat} = 1; + } elsif ($ARGV[0] eq "--auto") { + $opt{auto} = 1; + } else { + print STDERR "Error: unknown option $ARGV[0]\n"; + exit 1; + } + shift @ARGV; } - if (defined $ARGV[0] && $ARGV[0] eq "--auto") { - $opt{auto} = 1; + if ($opt{stat}) { + show_i2c_stats(); + exit 0; } # We won't go very far if not root