Welcome to little lamb

Code » anopa » commit 1fd90cc

reboot: Require an option of what to do

author Olivier Brunel
2015-02-27 17:40:49 UTC
committer Olivier Brunel
2015-04-04 12:47:35 UTC
parent 9814f935b3b30d554f1c5aab11897ea1de380622

reboot: Require an option of what to do

To avoid issue if confusing aa-reboot with aa-shutdown.

doc/aa-reboot.pod +3 -3
src/utils/aa-reboot.c +6 -6

diff --git a/doc/aa-reboot.pod b/doc/aa-reboot.pod
index 9812e99..3294ced 100644
--- a/doc/aa-reboot.pod
+++ b/doc/aa-reboot.pod
@@ -1,10 +1,10 @@
 =head1 NAME
 
-aa-reboot - Reboots, powers off or halts the machine
+aa-reboot - Reboots, powers off or halts the machine instantly
 
 =head1 SYNOPSIS
 
-B<aa-reboot> [B<-r> | B<-p> | B<-H>]
+B<aa-reboot> B<-r> | B<-p> | B<-H>
 
 =head1 OPTIONS
 
@@ -24,7 +24,7 @@ Powers off the machine.
 
 =item B<-r, --reboot>
 
-Reboots the machine. This is the default if no other option is specified.
+Reboots the machine.
 
 =item B<-V, --version>
 
diff --git a/src/utils/aa-reboot.c b/src/utils/aa-reboot.c
index 96faef8..147c5fd 100644
--- a/src/utils/aa-reboot.c
+++ b/src/utils/aa-reboot.c
@@ -10,10 +10,10 @@ const char *PROG;
 static void
 dieusage (int rc)
 {
-    aa_die_usage (rc, "[OPTION]",
-            " -r, --reboot                  Reboot the machine; This is the default\n"
-            " -H, --halt                    Halt the machine\n"
-            " -p, --poweroff                Power off the machine\n"
+    aa_die_usage (rc, "OPTION",
+            " -r, --reboot                  Reboot the machine NOW\n"
+            " -H, --halt                    Halt the machine NOW\n"
+            " -p, --poweroff                Power off the machine NOW\n"
             " -h, --help                    Show this help screen and exit\n"
             " -V, --version                 Show version information and exit\n"
             );
@@ -32,7 +32,7 @@ main (int argc, char * const argv[])
         { .cmd = RB_POWER_OFF,   .desc = "power off" },
         { .cmd = RB_AUTOBOOT,    .desc = "reboot" }
     };
-    int i = 2;
+    int i = -1;
 
     for (;;)
     {
@@ -76,7 +76,7 @@ main (int argc, char * const argv[])
     argc -= optind;
     argv += optind;
 
-    if (argc != 0)
+    if (argc != 0 || i < 0)
         dieusage (1);
 
     if (reboot (cmd[i].cmd) < 0)