sensors-detect: Rework option handling

Rework the way command line options are handled. If we ever need more
than this, we should consider moving to some GetOpt perl module.
This commit is contained in:
Jean Delvare committed 2013-09-11 11:51:57 +00:00
1 parent 5b6f3f26e0
commit ec4160f771
2 files changed
+15 -6

No files matched your search

+1
View File
@@ -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
+14 -6
View File
@@ -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